Quick Reference Study Notes for Linux Operating System (Advanced)

Linux operating system

Linux operating system is a open-source operating systems built around the Linux kernel. Typically, Linux is packaged in a form known as a Linux distribution for both desktop and server use.

The interesting thing is that most people only need to use a very small subset of those commands. Below is a “cheat sheet” with some of the most commonly used commands with descriptions.

 

Command

Description

uname -a

Display Linux system information

uname -r

Display kernel release information

cat /etc/redhat-release

Show which version of redhat installed

uptime

Show how long the system has been running + load

hostname

Show system host name

ifconfig

Display the IP addresses of the host

last reboot

Show system reboot history

date

Show the current date and time

cal

Show current month's calendar

w

Display who (user) is online

whoami

Who you are logged in as

cat /proc/cpuinfo

Display CPU information

cat /proc/meminfo

Display memory information

free -m

Display free and used memory ( -h for human readable, -m for MB, -g for GB.)

df -h

Show free and used space on mounted filesystems

fdisk -l

Display disks partitions sizes and types

du -ah

Display disk usage for all files and directories in human readable format

du -sh

Display total disk usage off the current directory

badblocks -s /dev/sda

Test for unreadable blocks on disk sda

top

Display and manage the top processes

htop

Interactive process viewer

ls

List all files and folder in a directory

ls -al

List all files in a long listing format

pwd

Display the present working directory

mkdir <directory name>

Create a directory

rm <file name>

Remove/Delete file

rm -r <directory name>

Remove the directory and its contents including sub-directories recursively

rm -f <file name>

Force removal of file without prompting for confirmation

rm -rf <directory name>

Forcefully remove directory recursively without prompting for confirmation

cp -r <source> <destination>

Copy source_directory recursively to destination

mv <source> <destination>

Rename or move a file

ln -s /source linkname

Create symbolic link to linkname

touch <file name>

Create an empty file or update the access and modification times of file

cat <file name>

View the contents of file

less <file name>

Browse through a text file

head <file name>

Display the first 10 lines of file

tail <file name>

Display the last 10 lines of file

tail -f <file name>

Display the last 10 lines of file and "follow" the file as it grows

cd

Go to the $HOME directory

cd <directory name>

Change to the /directory--name directory

cd ..

To go up one level of the directory tree

program &

Start program in the background

bg

Display stopped or background jobs

Ping <host>

Send ICMP echo request to host

tar -cf archive.tar <source directory name>

Create tar named archive.tar containing directory

tar -xf archive.tar

Extract the contents from archive.tar

tar -czf archive.tar.gz <source directory name>

Create a gzip compressed tar file name archive.tar.gz

tar -xzf archive.tar.gz

Extract a gzip compressed tar file

apt-get install <package name>

Install package

dpkg -i package.deb

Install package from local file named package.deb

apt-get remove <package name>

Remove/uninstall package

grep <pattern file>

Search for pattern in file

grep -r <pattern file>

Search recursively for pattern in directory

locate <name>

Find files and directories by name

find /home/john -name 'tomcat*'

Find files in /home/manav that start with "tomcat".

find /home -size +500M

Find files larger than 500MB in /home

ssh <host>

Connect to host as your local username.

ssh <user>@<host>

Connect to host as user

ssh -p <port> <user>@<host>

Connect to host using port

tail 100 /var/log/messages

groupadd demo

Display the last 100 syslog messages

Create a group named "demo"

useradd -c "Manav Sharma" -m manav

Create an account named manav, with a comment of "Manav Sharma" and create the user's home directory.

userdel manav

Delete the john account

usermod -aG demo manav

Add the john account to the demo group

scp file.txt <user@server>:/var/www/html

Secure copy file.txt to the /var/www/html folder on server

scp <user@server>:/var/www/*.html /var/www/html

Copy *.html files from server to the local /var/www/html folder.

rsync -a /home /backups/

Synchronize from /home to /backups

ps

Display your currently running processes

ps -ef

Display all the currently running processes on the system

ps -ef | grep <process name>

Display process information for process name

kill <pid>

Kill process with process ID of pid

killall <process name>

Kill all processes named process name

chmod [options] mode filename

Change a file’s permissions

chown [options] filename

Change who owns a file

clear

Clear a command line screen/window for a fresh start

man [command]

Display the help information for the specified command

passwd [name [password]]

Change the password or allow (for the system administrator) to change any password.


*NOTE : "This study material is collected from multiple sources to make a quick refresh course available to students."

This website uses cookies to improve user experience. By using our website you consent to all cookies in accordance with our Cookie Policy. More info. I Agree