• Health tips to prevent the spread of COVID-19:
    • Wash your hands frequently;
    • Maintain 2 meters social distancing;
    • Minimise outdoor activities.
    Stay safe in your bubble!

Andy

Administrator
User ID
1
Joined
7 Jan 2019
Messages
303
Reaction score
15
Points
18
On this page, you will find Basic Linux Commands and important ones in the title of Linux Cheat Sheet Commands. As you know Linux is widely used in Networking World. Network Engineers and System Administrators use these important operating system commands a lot in their daily routine or critical operational activities.

System Information Commands
uname -ashows Linux system info
uname -rshows kernel release info
cat /etc/redhat-releaseshows installed RedHat version
uptimedisplays system running/lifetime
hostnameshows system hostname
hostname -Ishows IP addresses of the host
last rebootdisplays system reboot history
datedisplays current date and time
caldisplays monthly calendar
mountshows mounted filesystems

File Commands
ls -lshows file type and access permission
ls -alists also hidden files
ls -allists files and directories detailly
pwdshows present directory
mkdir directorycreates a directory
rm xyzdeletes file xyz
rm -r /xyzdeletes directory /xyz and its contents recursively
rm -f abcforcefully deletes abc file without confirmation
rm -rf /xyzforcefully deletes directory /xyz recursively
cp aaa bbbcopies aaa file to bbb file
cp -r /xxx /yyycopies /xxx directıry to /yyy directory
mv aaa bbbrenames or moves file aaa to file bbb
touch abccreates an empty file named abc
cat abcused to view file abc
less abcbrowse through a text file abc
head abcdisplays first 10 lines of file abc
tail abcdisplays last 10 lines of file abc
tail -f abcdisplays last 10 lines of file abc and follow it as it grows
tail -F abcoutputs last lines of abc as it changes
file abcgets type of abc
gpg -c abcencrypts file abc
gpg abcdecrypts file abc
gpg abcdecrypts file abc
gpg abcdecrypts file abc
dirshows files in the current directory
put abcuploads file ‘abc’ from local to the remote device
get filedownloads file ‘abc’ from remote to local device

ls Options
-ashows all (including hidden)
-Rrecursive list
-rreverse order
-tsort by last modified
-Ssort by file size
-llong listing format
-1one file per line
-mcomma-separated output
-Qquoted output

Process Management Commands
psdisplays currently running processes
ps PIDgives the status of a particular process
pidofgives the process ID of a process
ps -efdisplays all running processes on the system
ps -ef | grep xyzdisplays process information for xyz
topdisplays and manages the top processes
htopinteractive process viewer (top alternative)
kill pidkills the process with the process ID of pid
pkill xyzkills the process with name xyz
killall abckills all processes named abc
program &starts a program in the background
bglists and resumes stopped jobs in the background
fgbrings the most recent background job to the foreground.
fg xbrings job x to the foreground
nicestarts a process with a given priority
renicechanges priority of an already running process
pstreedisplays processes in a tree-like diagram
pmapdisplays a memory usage map of processes
lsoflists files opened by running processes

Networking Commands
arpdisplays ARP table of the device
arpwatchdisplays ethernet activity and Ethernet/ip pairings
bmondisplays bandwidth, captures
curlused for file transfer
dhclientused to analyze clients IP address, subnet mask, gateway, DNS server
digused for simple DNS lookup
dstatcollects and shows system resources
ethtoolused to check settings of your NIC
ftpused for file transfer
hostused for IP-Name matchings
hping3used for packet analyze
ifstatused to monitor network interface statistics
ip addrused to check network interfaces and routing activities
iptablesused for IP packet filtering
iftopdisplays current bandwidth usage
ifup/ifdownused to enable or disable interfaces
iwconfigused to configure wireless interfaces
netstatto check network connections
nloadused as a bandwidth monitoring tool
nmapused for security audits
nslookupused also for DNS query
pingused to check reachability
routedisplays IP Routing Table
scpsecured file transfer
sftpsecured file transfer
ssgives detailed information about the sockets
sshused for secure connection
tsharkanalyzing and capturing
tcpdumpused for analyzing and capturing
telnetused for classical non-secure connection
tsharkused for packet analyze
tracepathused for path tracking
tracerouteused for path tracking
wused to check the current system activity
wgetused to download the content of the web servers
whoischecks the whois database and return with IP and Domain info

Help Commands
command -h / command –helpto review all available options of the “command”
info commandto find info documents about the “command”
whatis commanddisplays a single line description about the ”command”
$ man UNIXCOMMANDto view a detailed man page of the “command”
aproposused to search man pages for available commands on specific functionality.

User Information Commands
idshows user&group ids of the current user
lastshows the last users logged on
whoamishows who you are logged in as
whoshows who is logged into the system
wshows who is logged in and what they do
groupadd testcreates group “test”
useradd -c “AS” -m Andycreates “Andy” account with comment “AS”
userdel Andydeletes account “Andy”
usermod -aG Staff Andyadds account “Andy” to the “Staff” group

File Permissions
chown userchanges ownership of a file/directory
chown user:group filenamechanges user and group for a file or directory
File Permissionsr (read) permission, 4
w (write) permission, 2
x (execute) permission, 1
-= no permission
File Ownerowner/group/everyone
File Permissions Examples777 | Owner, Group, Everyone has rwx permissions

744 | Owner has rwx permission, Group, Everyone has r permission
755 | Owner has rwx permission, Group, Everyone has rx permissions
776 | Owner, Group has rwx permission, Everyone has rw permissions

Search Commands
grep x filesearches for x in a file
grep -icase insensitive search
grep -rrecursive search
grep -vinverted search
grep -oshows only matched part of the file
find /dir/ -name aaa*finds files starting with aaa in dir
find /dir/ -user Andyfinds files owned by Andy in dir
find /dir/ -mmin 10finds files modified less than 10 minutes ago in dir
find /home -size +500Mfinds files larger than 500MB in /xyz
find [/folder/location] -name [x]finds file names starting with character x
whereis aaalocates the binary, source, and manual page of aaa
locate abcfinds the location of abc quickly

File Transfer Commands
scp file.txt server:/tmpsecure copy file.txt to the /tmp folder on server
scp server:/var/www/*.html /tmpsecure copy *.html files in /var/www/ directory on server to the local /tmp folder
scp -r server:/var/www /tmpsecure copy all files and directories recursively from server to the current system’s /tmp folder.
rsync -a /home /backups/synchronize /home to /backups/
rsync -avz /home server:/backups/Synchronize files/directories between the local and remote system with compression enabled

Disk Usage Commands
dfshows free hard disk space on the system
df -hshows free and used space on mounted filesystems
df -ishows free and used inodes on mounted filesystems
fdisk -lshows free and used inodes on mounted filesystems
du -shshows total disk usage off the current directory
du -ahshows disk usage for all files and directories in a readable format
freeshows free RAM on the system
free -hshows free and used memory
findmntshows target mount point for all filesystem
mount /xyz /abcmounts a device in /xyz to /abc

Compress and Decompress Commands
gzip abccompresses abc file using gzip.
bzip2 abccompresses abc file using bzip2.
zip abc.zip abccompresses abc file into the archive abc.zip.
tar -czvf archive.tar.gz /home/temp2/compresses a full directory with all subdirectories
gzip -d xyz.gzextracts xyz.gz with gzip utility
gunzip xyz.gzextracts xyz.gz with gzip utility
bzip2 -d file.php.bz2extracts xyz.gz with bzip2 utility
bunzip2 file.php.bz2extracts xyz.gz with bzip2 utility
unzip xyz.zipextracts xyz.zip with zip utility
gunzip -c output.txt.gzto view the contents of both files without extracting
tar cf archive.tar directorycreates tar named archive.tar containing directory
tar xf archive.tarextracts the contents from archive.tar
tar czf archive.tar.gz directorycreates a gzip-compressed tar file name archive.tar.gz
tar xzf archive.tar.gzextracts a gzip-compressed tar file
tar cjf archive.tar.bz2 directorycreates a tar file with bzip2 compression
tar xjf archive.tar.bz2extracts a bzip2 compressed tar file

Install Commands
yum search keywordcompresses abc file using gzip.
yum install abcinstalls abc package
yum info abcdisplays description and summary info about abc package
rpm -i abc.rpminstalls a package from a local file named abc.rpm
yum remove abcRemove/uninstall abc package
yum list installedllists all installed packages with yum
yum search [keyword]finds a package by a related keyword
yum info [package_name]shows package information and summary
yum install [package_name.rpm]installs a package using the YUM package manager
dnf install [package_name.rpm]installs a package using the DNF package manager
apt-get install [package_name]installs a package using the APT package manager
rpm -i [package_name.rpm]installs a .rpm package from a local file
rpm -e [package_name.rpm]removes a .rpm package

Hardware Information Commands
dmesgdisplays messages in the kernel ring buffer
cat /proc/cpuinfodisplays CPU information
cat /proc/meminfodisplays memory information
lspci -tvdisplays PCI devices
lsusb -tvdisplays USB devices
dmidecodedisplays DMI/SMBIOS from BIOS
hdparm -i /dev/sdadisplays info about disk sda
hdparm -tT /dev/sdaperforms a read speed test on disk sda
badblocks -s /dev/sdatests for unreadable blocks on disk sda

If you find this page useful for your Linux works and if you like it, kindly share this page with your friends, with your colleagues, with your social media followers, etc.

Do not forget, knowledge increases by sharing 👍
 
 Short URL:
Top