- How to check Linux Kernel version of a system?
[root@localhost /]# uname
-a = all
-v = version
-r = release
[root@localhost /]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost /]# uname -v
#1 SMP Wed Mar 21 18:14:51 EDT 2018
[root@localhost /]# uname -r
2. How to check your system’s current IP address?
Old method – “ifconfig”
New method – “if addr show‘ or “if addr”
3. How to check for free disk space?
df = disk free
-ah = all + human readable
so, use “df -ah”
4. How to manage services on a system?
Old method: service [service_name] status
New method: systemctl status [service_name]
sshd status example shown below:
service sshd status
systemctl status sshd
5. How to check the size of a directory’s contents on disk?
du = disk use
-sh = short
so, use “du -sh [directory_path]”
*note: if you use ‘du var’ without -sh handle, it will display all files in that directory.
6. How to check open ports on a Linux server?
netstat = lists all ports, could be too much information, so have to trim it down.
-t = TCP, -u = UDP, -l = Listening, -p = program, -n = numeric
*note: ‘netstat -tupln’ has to run with a privilege to display the programs.
7. How to check CPU usage of a given process?
ps aux | grep [service_name]
top = shows top processes utilised, updates every 5 seconds.
ps aux | grep sshd
*You can also install ‘htop’ and see more graphical based process utilisation.
8. How to mount a new volume? Mounting a device.
ls /mnt = devices are usually mounted under root directory called ‘mnt’
mount /dev/sda2 /mnt = mount sda2 device to mnt mounting point
mount = list all mounted devices
To check what devices got mounted on boot-up, use ‘less /etc/fstab’
9. Finding out something you don’t know?
Use ‘man‘ pages.
10. What do you do when you cannot find an answer in a man page?
Search using Google, stack overflow, etc. on the internet.