Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Linux commands form the backbone of managing and operating a Linux system. Here are some basic Linux commands that are essential for beginners:
![](https://www.devsecopsnow.com/wp-content/uploads/2024/05/image-18.png)
![](https://www.devsecopsnow.com/wp-content/uploads/2024/05/image-19-1024x577.png)
File and Directory Commands
ls: Lists the contents of a directory.
sh
ls
ls -l # Detailed list with permissions, size, and modification date
ls -a # Includes hidden files
cd: Changes the current directory.
sh
cd /path/to/directory
cd .. # Move up one directory level
cd ~ # Move to the home directory
pwd: Prints the current working directory.
sh
pwd
mkdir: Creates a new directory.
sh
mkdir new_directory
rmdir: Removes an empty directory.
sh
rmdir directory_name
rm: Removes files or directories.
sh
rm file_name
rm -r directory_name # Recursively remove a directory and its contents
cp: Copies files or directories.
sh
cp source_file destination_file
cp -r source_directory destination_directory
mv: Moves or renames files or directories.
sh
mv old_name new_name
mv file_name /new/path/
touch: Creates an empty file or updates the timestamp of an existing file.
sh
touch new_file
File Viewing and Editing Commands
cat: Concatenates and displays the content of files.
sh
cat file_name
more: Views the content of a file one page at a time.
sh
more file_name
less: Similar to more, but allows backward movement in the file.
sh
less file_name
head: Displays the first few lines of a file.
sh
head file_name
head -n 20 file_name # Display the first 20 lines
tail: Displays the last few lines of a file.
sh
tail file_name
tail -n 20 file_name # Display the last 20 lines
nano/vim/gedit: Text editors for editing files directly from the command line.
sh
nano file_name
vim file_name
gedit file_name # GUI-based editor
System Information Commands
uname: Displays system information.
sh
uname -a
top: Displays running processes and system resource usage.
sh
top
df: Reports filesystem disk space usage.
sh
df
df -h # Human-readable format
du: Estimates file space usage.
sh
du
du -h # Human-readable format
free: Displays memory usage.
sh
free
free -h # Human-readable format
User Management Commands
whoami: Shows the current logged-in user.
sh
whoami
id: Displays user and group information.
sh
id
sudo: Executes commands with superuser privileges.
sh
sudo command
passwd: Changes the user password.
sh
passwd
Networking Commands
ping: Checks connectivity to a network host.
sh
ping hostname_or_ip
ifconfig: Configures network interfaces (deprecated, replaced by ip).
sh
ifconfig
ip: Shows/manages IP addresses and routing.
sh
ip addr
ip route
ssh: Connects to a remote machine via SSH.
sh
ssh user@hostname_or_ip
scp: Securely copies files between hosts.
sh
scp file user@remote_host:/path/to/destination