Very useful Linux commands
Another way to get the uptime of the system.
awk '{printf("Uptime: %d:%02d days, %02d minutes, %02d seconds.\n",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}' /proc/uptime |
Find the actual device name of the drive that contains your root partition.
ip-172-31-20-16:~> findmnt -n -o SOURCE / /dev/xvda1 |
Find the device name of a hard disk from the UUID identifier.
ip-172-31-20-16:~> findfs UUID=ee515a1e-7735-4529-822f-4cc9e7632cd3 /dev/xvda1 |
How to get the total disk space on your root partition and the free space as well.
ip-172-31-20-16:~> df -h --total / Filesystem Size Used Avail Use% Mounted on /dev/xvda1 30G 26G 2.6G 92% / total 30G 26G 2.6G 92% - |
This command will show the amount of disk space in megabytes that a directory takes up.
ip-172-31-20-16:~> du -ack -BM /boot | tail -n 2 270M /boot 270M total |
How to get just the IP address of a website with one useful Linux command.
ip-172-31-20-16:~> dig google.com.au a +short 216.58.199.35 |
It is possible in a few ways, to get the filesystem type of a partition with a simple command. I am getting it with the df command.
localhost% df -BM -T /dev/mapper/fedora-root Filesystem Type 1M-blocks Used Available Use% Mounted on /dev/mapper/fedora-root ext4 234550M 94357M 128256M 43% / |
The file command may also be used to get information about the filesystem on a partition.
[root@localhost jason]# file -sL /dev/mapper/fedora-root /dev/mapper/fedora-root: Linux rev 1.0 ext4 filesystem data, UUID=0fb483da-17ac-45a9-a665-9becb78210f3, volume name "Fedora" (needs journal recovery) (extents) (64bit) (large files) (huge files) |