
The ultimate Linux command cheat sheet for developers
By Louise Willoughby | 17 May 24
Linux commands are a series of commands used to interact with the Linux operating system. Whether you want to remove files, compress files or check the uptime of your server, almost anything is possible with some basic Linux commands. The more commands you learn, the more tasks you can do. Let’s take a look at the new command line you’ll love using!
Basic Unix Commands
Let’s start with some basic commands. Whether you want to manage files, confirm current system status, or copy files using the CP command, with these basic unix commands, you can get a lot done!
- ls: Lists directory contents.
- cd: Changes the current directory.
- pwd: Prints the current working directory.
- mkdir: Creates a new directory.
- touch: Creates a new file or updates the timestamp of an existing file.
- rm: Removes files or directories.
- cp: Copies files or directories.
- mv: Moves files or directories.
- cat: Concatenates and displays the content of files.
- grep: Searches for patterns in files.
- chmod: Changes file permissions.
- chown: Changes file ownership.
- sudo: Executes a command with superuser privileges.
- man: Displays the manual pages of commands.
- clear: Clears the terminal screen.
The ultimate Unix command guide for any operating system
Now that you know the basics, let’s dive a bit deeper. While the previous commands give you a head start, these allow you to control all the files on your system. We’d recommend saving this guide to keep it handy.
File Operations
- less: View file content page by page
- head: Display the beginning of a file
- head -n 10 filename: Display the first 10 lines of a file
- tail: Display the end of a file
- tail -n 10 filename: Display the last 10 lines of a file
- nano or vi: Text editors for creating or editing files
- grep -i: Perform case-insensitive search
- grep -r: Search recursively in directories
- find: Search for files and directories
- find /dir -name “filename*”: Search for files with a specific name
- diff: Compare files line by line
File Permissions
- chmod 755 filename: Give read, write, execute permissions to owner, and read, execute permissions to group and others
- chown user:group filename: Change owner and group of a file
- chgrp: Change group ownership of a file or directory
- setfacl: Set file access control lists
System Information
- top: Display and update sorted information about system processes
- ps: Display information about active processes
- ps -ef: Display all processes
- df: Display disk space usage
- df -h: Display sizes in a human-readable format
- du: Display disk usage of files and directories
- du -sh *: Display total size of each directory in the current directory
- uptime: Display system uptime and load averages
- free -m: Display amount of free and used memory in the system
Networking
- ping: Send ICMP ECHO_REQUEST to network hosts
- ssh username@hostname: Connect to a remote host
- scp file.txt username@hostname:/remote/directory/: Securely copy file to remote host
- wget or curl: Download files from the internet
- wget -O filename URL: Download file and save with a specific name
Compression and Archiving
- tar -cvf: Create a new “tar” archive
- tar -xvf: Extract files from a “tar” archive
- tar -zcvf: Create a compressed “tar” archive (gzip)
- tar -zxvf: Extract files from a compressed “tar” archive (gzip)
- gzip or gunzip: Compress or decompress files using gzip
- gzip -9 filename: Compress files using maximum compression level
- gunzip filename.gz: Decompress gzip file
- zip or unzip: Package and compress (zip) or extract (unzip) files
Process Management
- kill: Terminate a process
- kill -9 PID: Forcefully terminate a process by PID
- killall: Terminate all processes by name
Miscellaneous
- date: Display or set the system date and time
- history: Display the command history
- history | grep keyword: Search command history for a specific keyword
Thank you for checking out Nimbus’ guide to Linux Commands. If this list of Linux commands has helped, don’t forget to save them for future reference.
Sources: