Linux Cheat Sheet
For DevOps
File and Disk Management User and Group Management
sudo useradd Creates a new user account with the
ls Lists files and directories in current directory
<username> specified username
Lists files and directories with information
sudo passwd Changes the password for the specified
ls -l such as permissions, ownership, size, and
<username> user
modification date
Lists all files and directories including hidden sudo userdel Deletes the specified user account from
ls -a ones <username> the system
sudo groupadd Creates a new group with the specified
cat -b Inserts line numbers to non-blank lines
<groupname> group name
sudo groupdel Deletes the specified group from the
cat -n Inserts line numbers to all lines
<groupname> system
sudo usermod -g
Modifies the primary group of the
Squeezes multiple blank lines into a single <groupname>
cat -s blank line while displaying the file contents specified user to the specified group
<username>
Displays contents of a file ending with a $ Displays the user ID (uid) and group ID
cat –E symbol in each line id (gid) of the current user
id -g Displays the group ID (gid) of the
chmod Changes permissions of a file or directory
<groupname> specified group
id -u Displays the user ID (uid) of the specified
chown Changes ownership of a file or directory
<username> user
Displays the user ID (uid), group ID (gid),
Copies raw data from one file/ device to id <username> and supplementary group IDs (sgid) of
dd another
specified user
tail Displays last 10 lines of a specified file Text Manipulation
Finds files and directories based on specific sort -r Sorts the output in reverse order
find criteria
Copies securely files between hosts on a sort -f Sorts the output ignoring the case
scp network using SSH (Secure Shell) protocol
df Estimates space used by entire file system sort -n Sorts the output numerically
Displays the amount of disk space used by Extracts specific portion from a file or
du individual file cut input stream
Compares two files and displays the
Process Management diff differences between them
Translates or deletes characters from
Interactive process viewer that displays tr standard input and writes to standard
htop system resource usage in real-time
output
Lists information about currently running sed Editor used for modifying text
ps processes
kill Sends a signal to a process to terminate it uniq Filters out duplicate lines in a file
history
Displays the list of previously executed
commands System Information
Displays the amount of free and used memory
in the system Displays the operating system name
uname -m Displays the machine hardware name
Prepared By: Lamisa Musharrat Copyright ©2023 linuxsimply.com| All rights reserved.
Linux Cheat Sheet
For DevOps
Package Management uname -r Displays the kernel release number
Handles packages on Ubuntu-based systems
lscpu Displays information about the CPU
sudo apt-get
remove
Removes a package from the system Text Searching
Performs a case-insensitive search
Network Configuration & Monitoring
Displays network interface configuration Displays the line numbers of the
ifconfig information, such as IP address, netmask, and grep -n
matched pattern
broadcast address
Displays all interface available even if those Inverts the search and displays all lines
ifconfig -a are down grep -v that do not match the pattern
Shows a count of the number of lines
ifconfig -s Displays short list of network interface grep -c that match the pattern
Displays and manages routing, devices, and
ip tunnels System Monitoring
Displays all IP addresses related with all Lists all files opened by any process of a
ip address network devices
system
Shows all network interfaces available on the
ip link system lsof -u username Lists all files opened by a user
Queries the DNS server for information about
nslookup a domain name or IP address Miscellaneous
route Access the Linux kernel's routing tables
Sets up, maintains, and inspects the tables of docker ps Lists all active Docker containers
iptables docker images Lists all Docker images on user’s
IPv4/IPv6 packet filter rules in the Linux kernel
machine
firewall
Displays network connections and network
Builds a Docker image from a
netstat statistics, such as active sockets, routing docker build
Dockerfile
tables, and network interface statistics
Creates a pair of public and private docker run Runs a Docker container
ss-keygen authentication keys
Client-server protocol used to establish a docker stop Stops an active Docker container
telnet connection to a remote computer
Scans hosts and services on a network, and
nmap provides information about operating systems, docker- compose up
Starts containers defined in a docker- compose.y
open ports, and services running on the hosts
Facilitates the transfer of data to or from a
server, using any of the protocols it supports, docker- Stops and removes containers defined in
curl
such as HTTP, HTTPS, FTP, FTPS, SCP, SFTP, compose down a docker-compose.yml file
TFTP, DICT, TELNET, LDAP, or FILE
Retrieves entries from databases, such as the use
Prepared Lamisa Copyright ©2023 linuxsimply.com| All rights
Linux Cheat Sheet
For DevOps
Git Commands
git init Initializes a new and empty Git repository
Creates a copy of a Git repository in a new directory from
git clone
an existing URL
Adds changes to the staging area in preparation for
git add
committing them to the repository
Records changes to the repository with a message
git commit
describing the changes
Shows the current status of the repository, including any
git status
changes that have been made but not yet committed
git show Displays information about a specific commit or object
git rm Removes files from the repository and stages the deletion
git remote Connects remote server with the local repository
git push Sends committed changes to a remote repository
Fetches changes from a remote repository and merges
git pull
them into the local repository
git branch Lists, creates, or deletes branches within the repository
Switches between different branches or creates a branch
git checkout
and switches to it
git merge Combines specified branch’s history into the current one
git rebase Moves all work from current to master branch
Prepared Lamisa Copyright ©2023 linuxsimply.com| All rights