Cheat Sheet for Common Linux Commands
Are you new to Linux? Are you struggling to understand the basics of the command line? Look no further! In this article, we'll be providing you with a cheat sheet filled with common Linux commands that will help you get started on your Linux journey.
What is Linux?
Linux is a free and open-source operating system that is commonly used in servers, supercomputers, and many other devices. It was first released on September 17, 1991, by a Finnish computer scientist, Linus Torvalds.
Why Use Linux?
Linux has many advantages, including the following:
- It is free and open-source.
- It is highly customizable.
- It is more secure than other operating systems.
- It is supported by a vast community of developers and users.
Command Line Basics
Before we dive into the commands, we need to understand some basic concepts of the command line.
A terminal is a program that allows you to interact with the command line. In Linux, you can open a terminal by pressing
The prompt is the text displayed in the terminal that indicates it is waiting for a command. The default prompt in Linux is the
Commands are instructions given to the system through the terminal. They are executed by pressing the
Arguments are additional information provided to a command to modify its behavior. They are separated from the command by a space.
Options are additional flags added to a command to modify its behavior further. They are preceded by a single or double hyphen.
Now that we have covered the basics, let's dive into the commands:
cd command is used to change the current working directory. Usage:
cd ~ # Go to home directory cd /path/to/dir # Go to a directory by absolute path cd dir # Go to a directory by relative path cd ../dir # Go back one directory
ls command is used to list the contents of a directory. Usage:
ls [options] [path]
ls # List contents of current directory ls -l # List contents in long format ls -a # List all contents, including hidden files ls dir/ # List contents of a directory
File and Directory Commands
mkdir command is used to create a new directory. Usage:
touch command is used to create a new file or update the timestamp of an existing file. Usage:
cp command is used to copy files or directories to a new location. Usage:
cp [source] [destination]
cp file.txt new_dir/ # Copy file to a directory cp -r dir/ new_dir/ # Copy directory to a new location cp -r dir/ new_dir/new_dir2/ # Copy directory and its contents recursively
mv command is used to move files or directories to a new location or rename them. Usage:
mv [source] [destination]
mv file.txt new_dir/ # Move file to a directory mv file.txt new_file.txt # Rename file mv dir/ new_dir/ # Move directory to a new location mv dir/ new_dir/new_dir2/ # Move directory and its contents recursively
rm command is used to remove files or directories. Usage:
rm [options] [path]
rm file.txt # Remove a file rm -r dir/ # Remove a directory and its contents recursively rm -rf dir/ # Remove a directory and its contents recursively, forcefully
System Information Commands
uname command is used to display the system information. Usage:
uname # Display the operating system name uname -a # Display all system information
top command is used to display real-time information about running processes. Usage:
df command is used to display disk usage statistics. Usage:
df [options] [path]
df # Display disk usage for all partitions df -h # Display disk usage in human-readable format df /dev/sda1 # Display disk usage for a specific partition
User and Permission Commands
whoami command is used to display the current username. Usage:
passwd command is used to change the password of a user. Usage:
chmod command is used to change the permissions of a file or directory. Usage:
chmod [permissions] [path]
chmod 755 file.txt
Package Management Commands
apt command is used to manage packages on Debian-based systems. Usage:
apt [options] [command] [package]
sudo apt update # Update the package lists sudo apt upgrade # Upgrade installed packages sudo apt install git # Install a package sudo apt remove git # Remove a package sudo apt autoremove # Remove dependencies of uninstalled packages
yum command is used to manage packages on Red Hat-based systems. Usage:
yum [options] [command] [package]
sudo yum update # Update the package lists sudo yum upgrade # Upgrade installed packages sudo yum install git # Install a package sudo yum remove git # Remove a package sudo yum autoremove # Remove dependencies of uninstalled packages
In conclusion, by mastering these common Linux commands, you are on your way to becoming a Linux command line wizard. We hope that this cheat sheet has been helpful and that you find it useful in your Linux journey! Happy command lining!
Editor Recommended SitesAI and Tech News
Best Online AI Courses
Classic Writing Analysis
Tears of the Kingdom Roleplay
Multi Cloud Ops: Multi cloud operations, IAC, git ops, and CI/CD across clouds
Crypto Rank - Top Ranking crypto alt coins measured on a rate of change basis: Find the best coins for this next alt season
Graph Reasoning and Inference: Graph reasoning using taxonomies and ontologies for realtime inference and data processing
LLM Book: Large language model book. GPT-4, gpt-4, chatGPT, bard / palm best practice
Learn Prompt Engineering: Prompt Engineering using large language models, chatGPT, GPT-4, tutorials and guides