0% found this document useful (0 votes)
118 views

Linux Cheat Sheet

This document provides a cheat sheet of common Linux commands organized by category including system information commands, file permission commands, network commands, hardware information commands, user management commands, and compression/package management commands. Key commands include uname and uptime for system info, chmod and chown for permissions, ifconfig and ping for networking, lshw and lspci for hardware, adduser and groupadd for users, and tar, gzip, rpm and dnf for compression and packages. The cheat sheet lists the command syntax and brief description for each command.

Uploaded by

Paulo GP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views

Linux Cheat Sheet

This document provides a cheat sheet of common Linux commands organized by category including system information commands, file permission commands, network commands, hardware information commands, user management commands, and compression/package management commands. Key commands include uname and uptime for system info, chmod and chown for permissions, ifconfig and ping for networking, lshw and lspci for hardware, adduser and groupadd for users, and tar, gzip, rpm and dnf for compression and packages. The cheat sheet lists the command syntax and brief description for each command.

Uploaded by

Paulo GP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

LINUX COMMANDS CHEAT SHEET

System File Permission

uname Displays system information: kernel version, chmod 644 /data/ Sets the permissions of the file data test.c to / /
machine type, and more. test.c be /
read write for the owner, and read-only for

uname -r Displays the running Linux kernel's release the group and others.

version. chmod 755 /dir1 Assigns read, write, and execute permissions

uptime Shows current time, system uptime, users, to the owner, and read and execute

and load averages. permissions to the group and others for the

hostname Shows the system hostname


directory dir1. /
hostname -i Displays the IP address of the current host.
chown bob:devops Changes file 'filename' ownership to ' bob' and
filename 'devops'.
last reboot Shows last reboot times and durations in
logs.
chown Change owner and group of the directory.
ownername:groupn
date Displays the current date and time ame directory
information.

timedatectl Displays detailed system clock and time zone Network


information.
ip addr show Displays all network interfaces and their
cal Displays a simple calendar of the current
information.
month.
ip address add Assigns IP address 192.168.0. 1 to interface
w Shows who is logged on and their activity.
192.168. 0. /2
1 4 dev eth .0
whoami Displays the username of the current user. eth 0
finger username Displays information about a user named ifconfig Shows network interfaces and their
'username'. configuration.

Hardware
ping host Sends I C MP packets, measures round-trip
time to "host".

dmesg Displays messages from the kernel's ring whois domain Retrieves and displays domain's registration
buffer. information.

/ /
cat proc cpuinfo Displays detailed information about the C PU. dig domain Queries DNS, provides domain's DNS

cat /proc/meminfo
information.
Displays detailed system memory usage
information. dig -x host Resolves IP address to hostname, shows DNS
information.
lshw Lists detailed hardware configuration of the
system. host google.com Performs an IP lookup for the domain name

lsblk Lists information about all available block wget file_ path Downloads file from specified path.
devices. netstat Displays various network-related information
free -m Shows system memory usage in megabytes. and statistics.

lspci -tv Displays P C I devices in tree format,


verbosely.
Compression / Archives

lsusb -tv Shows US B devices as a tree, verbosely. tar -cf backup.tar / Creates a tar archive of /home/u buntu

dmidecode Displays hardware information from system home ubuntu / directory.


BIOS tar -xf backup.tar Extracts files from "backup.tar" archive.
hdparm -i dev sda / / Displays information of disk dev sda. / / tar -zcvf Creates compressed "backup.tar.gz" archive
badblocks /
-s dev / Checks /dev/sda for bad blocks, showing backup.tar.gz / of /home/u untu
" b "

sda progress. home ubuntu /


gzip file1 Compresses "file1" into "file1.gz", original is
User Management removed.

id Displays the user's UID, GID, and groups.


Install Packages
last Shows list of last logged-in users.

who Displays who is currently logged in. rpm -i Installs the package "pkg _ name.rpm" using

groupadd admin Creates a new user group named admin. pkg _ name.rpm RPM Package Manager.

adduser Sam Creates a new user account named Sam. rpm -e pkg _ name Uninstalls the specified RPM package.

dnf install pkg _ name Installs the specified package using DNF.
userdel Sam Deletes the user account named Sam.
pacman -S Installs the specified package using Pacman.
usermod Modifies properties of an existing user
pkg _ name
account.

Install Source (Compilation)


File Commands
/
. configure Checks system compati bility and generates
ls -al Lists all files, detailed information, in long makefile for software installation.
format.
make Compiles code by following instructions in the
pwd Displays the present working directory's path. Makefile.

mkdir dir1 Creates a new directory named dir . 1 make install Installs compiled code into specified system
rm file1 Deletes the file named file1. locations.

rm -f file2 Forcefully deletes the file named file2.


Search
rm -r dir1 Recursively removes directory dir1 and its
contents. grep pattern file Search for a given pattern within the file.
rm -rf dir1 Forcefully deletes directory dir1 and its grep -r pattern dir1 Recursively searches for the specified
contents. "pattern" within the "dir1" directory and its
cp file1 file2 Copies file , creating or overwriting file2.
1 subdirectories

cp -r dir1 dir2 Copies dir to dir2, including su directories.


1 b locate file Finds files named "file" using prebuilt

mv file1 file2 Renames or moves file1 to file2. database.

/
ln -s path to / / Creates sym bolic link named link_ name to /
find home -name Searches " /home " directory for files named

file_ name link_ name file_ name. index "index" recursively.

touch file1 Creates an empty file named file . /


find home -size Finds files over 1 0000k si ze /
in home
+ 0000k
1

cat > file1 Creates/overwrites file , awaiting standard


1
1 directory.

input.
Login
more file1 Displays file1 content, paginating through
output. ssh user @hostname Initiates SS H connection to specified
head file1 Displays the first ten lines of file1. hostname.

tail file1 Displays the last ten lines of file1. ssh -p port_ number Initiates SS H connection using specific port.
gpg -c file1 Encrypts file1 with symmetric cipher using user @hostname
passphrase. Connect to the host Securely connect to the system via SS H
via telnet default default port 22
gpg file2.gpg Decrypts file2.gpg, prompting for the
port 23
passphrase.

wc Counts words, lines, and characters in files. telnet host Connect to the host via telnet default port 23.
xargs Executes commands with piped or file- File Transfer
provided arguments.
scp file.txt Copies file.txt to remote host's specified
Process Related remoteuser @remote directory.
_host:/remote/
ps Displays a snapshot of current processes. directory
ps aux | grep telnet Displays running telnet processes with rsync -a home / / Synchronizes content from source directory
details. ubuntu / backup / to destination directory,preserving attributes.
pmap Shows memory map of a process. rsync -a var www / / / Synchronizes local directory to remote,
top Displays dynamic real-time view of running web / preserving attributes.
tasks. user@remote host:/ _

kill 1234 Terminates the process with PID 1234. backup/


we ackup/
b_b
killall proc Kills all processes named 'proc'.
pkill process-name Terminates processes with the name. Disk Usage
bg Resumes suspended jobs in the background

fg Brings a suspended job to foreground df -h Displays human-readable disk space usage


for all mounted filesystems.
fg n Brings job number 'n' to foreground.
df -i Displays inode usage information for all
lsof Lists all open files and processes.
mounted filesystems.
renice 19 PID Changes priority of process with given PID.
fdisk -l Lists all partitions and their information on all
pgrep firefox Displays Process ID (s) for firefox processes. drives.

pstree Displays a tree of running processes. du -sh dir1 / Displays summary of total disk usage size of /
dir1, human-readable.

findmnt Displays a list of all mounted filesystems and


their properties.

mount device-path Mounts the device at the specified filesystem


mount-point mount point.

Directory Traverse

cd .. Navigate to the parent directory.

cd Changes the current directory to the user's


home.

cd mnt / Changes the current directory to /mnt . " "

You might also like