Linux Command

Krishna Neupane

System Information Commands

CommandDescription
uname -aDisplay Linux system information
uname -rDisplay kernel release information
cat /etc/os-releaseShow operating system information such as distribution name and version
uptimeShow how long the system has been running + load
hostnameShow system host name
hostname -IDisplay all local IP addresses of the host.
last rebootShow system reboot history
dateShow the current date and time
calShow this month's calendar
wDisplay who is online
whoamiWho you are logged in as

HARDWARE INFORMATION

CommandDescription
dmesgDisplay messages in kernel ring buffer
cat /proc/cpuinfoDisplay CPU information
cat /proc/meminfoDisplay memory information
free -hDisplay free and used memory (-h for human readable, -m for MB, -g for GB.)
lspci -tvDisplay PCI devices
lsusb -tvDisplay USB devices
dmidecodeDisplay DMI/SMBIOS (hardware info) from the BIOS
hdparm -i /dev/sdaShow info about disk sda
hdparm -tT /dev/sdaPerform a read speed test on disk sda
badblocks -s /dev/sdaTest for unreadable blocks on disk sda

PERFORMANCE MONITORING AND STATISTICS

CommandDescription
topDisplay and manage the top processes
htopInteractive process viewer (top alternative)
mpstat 1Display processor related statistics
vmstat 1Display virtual memory statistics
iostat 1Display I/O statistics
tail -100 /var/log/messagesDisplay the last 100 syslog messages (Use /var/log/syslog for Debian based systems.)
tcpdump -i eth0Capture and display all packets on interface eth0
tcpdump -i eth0 'port 80'Monitor all traffic on port 80 (HTTP)
lsofList all open files on the system
lsof -u userList files opened by user
free -hDisplay free and used memory (-h for human readable, -m for MB, -g for GB.)
watch df -hExecute "df -h", showing periodic updates

USER INFORMATION AND MANAGEMENT

CommandDescription
uname -aDisplay Linux system information
uname -rDisplay kernel release information
cat /etc/os-releaseShow operating system information such as distribution name and version
uptimeShow how long the system has been running + load
hostnameShow system host name
hostname -IDisplay all local IP addresses of the host.
last rebootShow system reboot history
dateShow the current date and time
calShow this month's calendar
wDisplay who is online
whoamiWho you are logged in as
idDisplay the user and group ids of your current user.
lastDisplay the last users who have logged onto the system.
whoShow who is logged into the system.
wShow who is logged in and what they are doing.
groupadd testCreate a group named "test".
useradd -c "Krishna Neupane" -m krishnaCreate an account named Krishna, with a comment of "Krishna Neupane" and create the user's home directory.
userdel KrishnaDelete the Krishna account.
usermod -aG sales krishnaAdd the krishna account to the sales group

FILE AND DIRECTORY COMMANDS

CommandDescription
ls -alList all files in a long listing (detailed) format
pwdDisplay the present working directory
mkdir directoryCreate a directory
rm fileRemove (delete) file
rm -r directoryRemove the directory and its contents recursively
rm -f fileForce removal of file without prompting for confirmation
rm -rf directoryForcefully remove directory recursively
cp file1 file2Copy file1 to file2
cp -r source_directory destinationCopy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with the contents of source_directory.
mv file1 file2Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2
ln -s /path/to/file linknameCreate symbolic link to linkname
touch fileCreate an empty file or update the access and modification times of file.
cat fileView the contents of file
less fileBrowse through a text file
head fileDisplay the first 10 lines of file
tail fileDisplay the last 10 lines of file
tail -f fileDisplay the last 10 lines of file and "follow" the file as it grows.

PROCESS MANAGEMENT

CommandDescription
uname -aDisplay Linux system information
uname -rDisplay kernel release information
cat /etc/os-releaseShow operating system information such as distribution name and version
uptimeShow how long the system has been running + load
hostnameShow system host name
hostname -IDisplay all local IP addresses of the host.
last rebootShow system reboot history
dateShow the current date and time
calShow this month's calendar
wDisplay who is online
whoamiWho you are logged in as
psDisplay your currently running processes
ps -efDisplay all the currently running processes on the system.
ps -ef | grep processnameDisplay process information for processname
topDisplay and manage the top processes
htopInteractive process viewer (top alternative)
kill pidKill process with process ID of pid
killall processnameKill all processes named processname
program &Start program in the background
bgDisplay stopped or background jobs
fgBrings the most recent background job to foreground
fg nBrings job n to the foreground

Follow me on : Medium Linkedin Researchgate