Basic Linux TutorialIntroduction – What is it? Why to learn? Linux installation directory structures Boot process Run levels in Linux Desktop Environments Different shells BASH Internal and External Commands Basic Linux Commands Important files and directories in Linux Environmental and Shell Variables Command history in Linux Character classes in Linux Text editors vim nano Searching files Creating new files Viewing File Contents File commands File permissions and ownership WildCards (Globbing) in files File compression Directory commands xargs command in Linux Comparing files Searching patterns using grep command Translating the characters using tr command Extracting data using cut command Stream editing using sed command Data extraction and reporting using awk command Sorting the file or string input uniq command in Linux Difference between grep, tr, cut, sed and awk commands Hardware commands Hard disk and memory space commands Working with Processes Managing Jobs Working with cron jobs Service command in Linux Network commands Managing Users and Groups Other Popular commands Standard streams and Redirection Pipes Package Managers in Linux
disk commands in linux shellHere is the list of hard disk and file system commands in Linux.
mount and unmount commandmount command is used to mount the file system in Linux. For example if you want to access the files from USB drive, you will have to first mount the file system from USB drive in the Linux System. Below example shows how to mount a file system on specific directory.
You can also modify “/etc/fstab” file to mount the file system. “fstab” stands for file system table. This file contains entries for all mounted file systems.
$ mount <file-system> <mount-directory>
df command“df” command stands for disk free. As the name indicates, it displays how much space is used by specific file system. It also shows how much space is available on specific file system. To display the size in human readable format (MG,GB,TB etc), you can use below command.
du command“du” stands for disk usage. This command is used to display the space occupied by specific file or a directory. For example – below command will display the space occupied by /etc directory and all files and sub-directories in it. “-h” will display the usage in human readable format (MB, GB,TB etc) and “-c” will display the total usage in the end.
Finding the size of each directory as well as file
du -hc /etc
Finding the size of entire directory
$ du -ah
Finding the size of all files and directories in only current directory
$ du -sh
$ du -ah -maxd 1
free commandfree command is used to show the details of RAM in Linux. By default RAM is displayed in KB. But you can use below commands to show the RAM in MB, GB, TB etc.
free -m free -g free -t
quota command in Linuxquota command is used to manage the disk quota of an user or group. Assume that you set up 15 GB as hard limit quota and 14 GB as soft limit quota with grace period as 10.
- Hard limit – With 15 GB as hard limit quota, user will not be allowed to store any more files after 15 GB space is used.
- Soft limit – With 14 GB as soft limit quota, user will be given warning messages after disk usage exceeds 14 GB
- Grace period – Grace period allows you to store files even though you have crossed hard limit.
Getting disk information of the systemYou can use lshw command to get disk information. As you can see there are 2 types of disks attached to the system – /dev/cdrom (DVD reader) and /dev/sda (ATA Disk)You can use lsblk command to display the block devices and mount points. You can use fdisk command to manage the partitions of specific disk.
Complex problems, Simple Solutions