Home » Linux

Linux Essentials Command Line Cheat Sheet

Linux Essentials command line cheat sheet: In this article, we have listed some of the most popular Linux commands.
Submitted by Aleesha Ali, on June 18, 2018

Operators && - and, || - or
apropos Returns all documentation containing the defined command
bzip/bunzip - bzip Compresses files
cat Outputs the contents of a file
cd Change directory
chmod Change file mode
chown Change ownership
clear Clears the screen
cp Copy
-f Force; will overwrite any existing files with the same name
-i Interactive; will ask to overwrite
-p Preserves file ownership
-r Recursive; will copy files under directories
-a Archive; preserve symlinks
-u Copy only if original file is newer
cut Manipulate data by columns
-c Range to cut [-c2-4]
-d Define a deliminator to use with fields
-f Return the numbered field
dig Look up IP addresses and DNS names
env Show environmental variables for current user
exit Terminates all current processes, including shell
find Locate file in system
finger Used to find out information regarding a user
free Reports on system memory
grep search for string
-i Case insensitive
-n Include line number in output
groupadd Add group
-g Group ID
-p Password
-r Create system group
groupmod Modify group
-g GID
-p Password
head Output the first ten lines of a file
halt Shuts down operating system
id Outputs user and group IDs for a user
-u Show only UID
-g Show only GID
-G Show all groups to which a user belongs
-Gn Group name
if Conditional statements in bash scripting
-d See if directory exists
-e See if file exists
-f See if file exists and it is a regular file
-G See if file exists and it is owned by a defined group
-h See if file exists and it is symlinked
-L See if file exists and it is symlinked (same as -h)
-O See if file exists and it is owned by defined UID
-r See if file exists and has read permissions
-w See if file exists and had write permissions
-x See if file can be executed
ifconfig Shows NIC for network card; configures network settings
info Improved manual pages
init 0 Shuts down operating system
init 6 Reboots the operating system
ipaddr Replaces ifconfig on newer systems
last hows last command used by defined user
less Opens file in a vim-like environment for viewing
ln link files
-s Create symbolic link
ls List contents of directory
-a List all files, including hidden files
-l List files, including details such as owner and permissions
-p Adds a / to the end of directories
-R Enable recursion, including all sub-directories
man Manual pages
1 Executable programs and shell commands
2 System calls for the kernel
3 Library calls
4 Device files
5 File formats
6 Games
7 Misc.
8 Programs only run by the root user
9 Kernel routines
-k Returns all documentation containing search keyword (apropos)
mv/move Used to move or rename files
-m Set permissions mode
-p Force recursion
netstat Shows network status
-a All listening and non-listening sockets
-i Network interface statistics
-l Listening sockets
-s Summary of each protocol
passwd Change/set password
-S View password settings
-l Locks account
-u Unlocks account
-d Remove password
-n Set days before password change
-x Set maximum days before password change
-w Days to warn prior to password reset
-i Days to wait after expired password to disable account
ping Test connectivity of remote network device
ps Process status
-u Define user
pwck Verifies the integrity of the password files
pwconv Syncs /etc/passwd and /etc/shadow
pwd Print working directory
reboot Shuts down, then restarts the system
route View routing tables
set - similar to env Works with environment variables
sort Sorts text in file
-r Sort in reverse order
-n Sort numerically
su Substitute user
sudo Run command as root
tail Outputs the last ten lines of a file
rm Remove
-r Enable recursion
rmdir Remove directory
shutdown Shuts down the system
-H Halts the machine
-P Power off
-r Reboot
-h Equivalent to powering off, overridden by --halt
-k Send warning, but perform no actions
-c Cancel a shutdown
su Substitute user
tar Archives files
-cf Create file
-xf Extract file
-v Verbose
-zcf Archive with gzip
-jcf Archive with bzip2
top Shows list of current applications/processes, and system usage
h Help
k Input process ID to kill
r Change process priorety
p Sort by CPU usage
m Sort by memory usage
touch Created empty file
-c Will not create file if one exists; will update timestamp
-d Manually set timestamp; can be used with directories
traceroute Traces the route a packet takes
uname Returns information related to the system
-s Displays kernel name
-n Displays hostname
-r Kernel release number
-v Kernel version number
-m Hardware architecture
-p Processor architecture
-i Hardware platform
-o Operating system
-a All information
useradd Adds new user
-D Outputs defaults
-c Comment
-e When to expire account
-f Number of days after password expiration to disable account
-g Default group
-G Additional groups
-M Do not create home directory
-m Set home directory
-p Define password
-r Create system user
-s Set default shell
-u Define UID
userdel Delete user
-r Delete home folder
usermod Modify user account
-c Comment
-e Expire date
-f Days after password expiration to disable account
-G Add groups
-l Change username
-L Lock account
-m Move home directory
-p Change password
-u Set user ID
-U Unlock account
w Displays user system information
wc Word count
-w Count words
-c Count characters
whatis Returns available man pages for command
which Shows location of application
who Displays who is logged in
-b Last boot time of machine
-m Hostname and associated user
-r Run level for current user
-q Number of logged-in users
-a All
whoami Outputs username of current user
zip/unzip - zip; Compresses files

Comments and Discussions!

Copyright © 2023 www.includehelp.com. All rights reserved.