Here you have a compilation of the most useful Linux commands, so you can make the most of your favorite operating system.
Of course, there are many more, and countless possible combinations (some truly long and impossible to remember). If you have any contributions, I would be happy to receive them.
Process and Job Control
View Active Processes
Displays the processes that are running on the system.
ps aux
Terminate a Process
Ends a specified process by its PID.
kill PID
Run a Process in the Background
Sends a command to the background.
command &
List Background Jobs
Displays the processes that are in the background.
jobs
Bring a Background Process to the Foreground
Restores a process to the foreground.
fg %n
System Information and Monitoring
View CPU and Memory Usage
Displays real-time CPU and memory usage of the system.
top
Detailed Memory Information
Shows details of memory usage.
free -h
Show Disk Space
Verifies disk space usage by partition.
df -h
System Information
Displays details about the operating system and hardware.
uname -a
View System Logs
Checks the system logs.
dmesg
File and Directory Operations
List Files
Lists the files in a directory, including hidden ones.
ls -la
Move Files or Directories
Moves files or directories to another location.
mv source destination
Copy Files
Copies files or directories.
cp file destination
Delete Files or Directories
Deletes files (or directories with the -r
option).
rm file
Create Directory
Creates a new directory.
mkdir directory_name
File Content Operations
Show File Content
Displays the content of a text file.
cat file
Show First Lines of a File
Displays the first 10 lines of a file.
head file
Show Last Lines of a File
Displays the last 10 lines of a file.
tail file
Concatenate and Show Files
Concatenates the content of files.
cat file1 file2
View Real-Time Updates of a File
Displays the content of a file that is being updated, useful for logs.
tail -f file
File and Content Search
Find a File by Name
Searches for files by name in a directory and its subdirectories.
find /path -name "file_name"
Search Within File Content
Searches for a string of text in files within a directory.
grep "text" *.txt
Find Recently Modified Files
Finds files modified within a specific time range.
find /path -mtime -n
User and Group Management
Add a New User
Creates a new user on the system.
sudo adduser username
Change a User’s Password
Changes a user’s password.
passwd username
Add a User to a Group
Adds a user to a specific group.
sudo usermod -aG group_name username
Delete a User
Removes a user from the system.
sudo deluser username
Permissions and Special Attributes
Change Permissions of a File
Changes the permissions of a file or directory (read, write, execute).
chmod 755 file
Change the Owner of a File
Changes the owner and group of a file.
chown user:group file
View File Permissions
Displays permissions and details of files.
ls -l
Packaged and Compressed Files
Compress Files in tar.gz
Creates a compressed file in tar.gz format.
tar -czvf file.tar.gz file
Decompress tar.gz Files
Extracts files from a tar.gz file.
tar -xzvf file.tar.gz
Compress Files in zip
Creates a compressed file in zip format.
zip file.zip file
Decompress zip Files
Extracts files from a zip file.
unzip file.zip
Package Managers and Repositories
Update Repositories
Updates the list of available packages.
sudo apt update
Install a Package
Installs a package from the repositories.
sudo apt install package_name
Remove a Package
Uninstalls a package from the system.
sudo apt remove package_name
Upgrade the Entire System
Upgrades all installed packages to the latest version.
sudo apt upgrade
File System Operations
Mount a File System
Mounts a device or partition to a directory.
sudo mount /dev/device /mount_point
Unmount a File System
Unmounts a device or partition.
sudo umount /dev/device
View Mounted File Systems
Displays the currently mounted file systems.
mount
Format a Partition
Formats a partition to a specific file system.
sudo mkfs -t ext4 /dev/device