LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-08-2021, 10:16 PM   #1
maxwell2k19
LQ Newbie
 
Registered: Apr 2021
Posts: 3

Rep: Reputation: Disabled
disk space


Hi All

i am new to linux and i am learning it. i have a disk space issue on one server

[root@server01 /]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sdb1 ext4 1000G 1000G 0 100% /data

i have used the below syntax to get the files above 100M

find /data -xdev -type f -size +100M | xargs du -sh * | sort -hr | head -30

i have a directory by name dir2 under /data/dir1/dir2 which is occupying space.it has lot of files each of 10MB.

1. how can i know how many files and directories this dir2 has.
2. How many files in the dir2 have above 10MB and less than 10MB
3. how can i know the files which have been modified in last 7 days in dir2.
4. i want to keep the files of last 7 days which includes modified files and delete the rest of the files in dir2. how can i delete.
5. To know the OS version will the command cat /etc/os-release give me OS version in RHEL,Centos,SUSE linux?
 
Old 04-08-2021, 11:04 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by maxwell2k19 View Post
1. how can i know how many files and directories this dir2 has.
To count the objects in that directory, you could use ls -a | wc -l. To count all objects in that directory and all its subdirectories, one method is find . | wc -l. wc stands for "word count" and can be used to count characters, words or lines. In this case, it counts lines.
Quote:
2. How many files in the dir2 have above 10MB and less than 10MB
Modify your find command for 10MB and pipe it into wc -l.
Quote:
3. how can i know the files which have been modified in last 7 days in dir2.
The find command has an option -mtime, which stands for "modification time".
Quote:
4. i want to keep the files of last 7 days which includes modified files and delete the rest of the files in dir2. how can i delete.
The rm command deletes files. You can use the -exec option to perform an action on each file that find finds, for example:
Code:
find -mtime +7 -exec rm {} +
Note that this will delete everything in subdirectories, not only the current directory. Use the -maxdepth option to change this behaviour. Also, it is your responsibility to test this command. Use it at your own risk.
Quote:
5. To know the OS version will the command cat /etc/os-release give me OS version in RHEL,Centos,SUSE linux?
The question is what you mean by "OS version". os-release is part of systemd and therefore available on those distros. It tells you the distro version, but not the kernel version. To know the kernel version that is currently running, use uname -r.

Last edited by berndbausch; 04-08-2021 at 11:07 PM.
 
1 members found this post helpful.
Old 04-09-2021, 07:48 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,753

Rep: Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983
Quote:
Originally Posted by maxwell2k19 View Post
Hi All
i am new to linux and i am learning it. i have a disk space issue on one server

[root@server01 /]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sdb1 ext4 1000G 1000G 0 100% /data

i have used the below syntax to get the files above 100M

find /data -xdev -type f -size +100M | xargs du -sh * | sort -hr | head -30

i have a directory by name dir2 under /data/dir1/dir2 which is occupying space.it has lot of files each of 10MB.

1. how can i know how many files and directories this dir2 has.
2. How many files in the dir2 have above 10MB and less than 10MB
3. how can i know the files which have been modified in last 7 days in dir2.
4. i want to keep the files of last 7 days which includes modified files and delete the rest of the files in dir2. how can i delete.
5. To know the OS version will the command cat /etc/os-release give me OS version in RHEL,Centos,SUSE linux?
Sorry, but these all sound VERY much like verbatim homework questions. We're happy to help you, but you have to show us your efforts. Can you tell us what you've done/tried for each of the things you listed?
 
Old 04-09-2021, 08:14 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
ncdu is a great tool to handle issues like this.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disk Space Used is Less Than Size Still Available Disk Space is Zero devUnix Linux - Server 10 10-04-2013 08:56 AM
Division of Logical Memory Space in to User Space and Kernel Space shreshtha Linux - Newbie 2 01-14-2010 09:59 AM
add space to / when from spare space on disk ctsiow Linux - General 4 11-07-2007 07:55 AM
Cedega "Disk space required for the installation exceeds available disk space" Solved Spewdemon LinuxQuestions.org Member Success Stories 1 10-18-2007 06:19 PM
3Gb of disk space lost! Disk space problem or mother board conflicts with HDD Mistreated Linux - Hardware 4 12-06-2004 03:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration