Top 40 Linux commands every sysadmin should know

Photo of author
By Jay
— 3 min read
Photo of author
Written by
Photo of author
Verified by
Published On
— 3 min read

Top 40 Linux commands every sysadmin should know

To get login user information, including the number of currently logged-in users and their processes:

# w

To see the list of users who are currently logged in and on which terminal they are logged in:

# who

To view the list of users who have logged in and out since the /var/log/wtmp file was created:

# last

To see the list of users who have attempted bad logins:

# lastb

To see the list of all reboots since the log file was created:

# last reboot

To see information about system uptime, including the time the system has been running, the number of logged-in users, and the load average:

# uptime

Note: The load average is displayed for 1 sec, 5 secs, and 15 secs intervals.

To view the mounted partitions, their mount points, and amount of disk space used:

# df

To see the disk usage of each file in bytes:

# du

To get the current kernel version:

# uname -r

To view the last shutdown date and time:

Move Paragraph block from position 21 up to position 20

Move Paragraph block from position 21 down to position 22

# last -x

To display only the shutdown time using grep:

# last -x | grep shutdown

Note: grep is used to search for a word or sentence in a file, and find is used to search for a command or file inside the system.

To view the list of shells supported by Linux:

# cat /etc/shells

or

# chsh -l

Default shells:

/bin/sh ------> default shell for Unix
/bin/bash ------> default shell for Linux
/sbin/nologin ------> users cannot login shell
/bin/tcsh ------> c shell to write 'C++' language programs
/bin/csh ------> c shell to write 'C' language programs

To see the current shell:

# echo $SHELL

To change the shell for a specific user:

# chsh <user name>

To display the time only:

# date + %R

To display the date only:

# date + %x

To see the history of commands:

# history

To clear the history of commands:

# history -c

To recover the history of commands:

# history -r

To check the current history size:

# echo $HISTSIZE

To change the current history size to 500 temporarily:

# export HISTSIZE=500

To display the date and time of each command temporarily:

# export HISTTIMEFORMAT=" "%D" "%T" "

To make history size and date & time formats permanent:

Open this file, go to the last line, and add the following lines

# vim /etc/bashrc

HISTSIZE=1000
HISTTIMEFORMAT=' %D %T '

(Save and exit the file, and update the effects by using the command:)

# source /etc/bashrc

To go to the user’s home directory:

# cd ~ <user name>

To see the short description of a command:

# whatis <command>

To see the location of a command and its documentation:

# whereis <command>

To refresh the terminal:

# reset

To see the current user name:

# whoami

To see the current user with full details like login time and others:

# whoami

To change the password of a user:

# passwd <user name>

To see the current user name, user ID, group name, and group ID:

# id

To see the specified user name, user ID, group name, and group ID:

# id <user name>

To switch to the root user without root user home directory:

# su

To switch to the root user with root user home directory:

# su -

To switch to a specified user without his home directory:

# su <user name>

To switch to a specified user with his home directory:

# su - <user name>

To list all the PCI slots present in the system:

# lspci

To see the size of /etc on the disk in KBs or MBs:

# du -sh /etc/

For more Linux commands Visit this Link All Linux Commands Help

Related Posts


About Author

Photo of author

Jay

I specialize in web development, hosting solutions, and technical support, offering a unique blend of expertise in crafting websites, troubleshooting complex server issues, and optimizing web performance. With a passion for empowering businesses and individuals online, I provide in-depth reviews, tech tutorials, and practical guides to simplify the digital landscape. My goal is to deliver clear, reliable, and insightful content that helps readers make informed decisions and enhance their online presence.

Leave a Comment