ls
- List Directory ContentsLists files and directories in the current directory.
ls # Lists all files and directories
ls -l # Lists with detailed information (permissions, owner, size, etc.)
ls -a # Lists all files including hidden files
ls -lh # Lists with human-readable file sizes
cd
- Change DirectoryChanges the current working directory.
cd /path/to/directory # Navigate to specified directory
cd ~ # Navigate to home directory
cd .. # Move up one directory level
cd - # Go to the previous directory
pwd
- Print Working DirectoryDisplays the current directory path.
pwd # Prints the full path of the current directory
cp
- Copy Files and DirectoriesCopies files or directories from one location to another.
cp source.txt destination.txt # Copy file
cp -r /source/directory /destination/ # Copy directory recursively
mv
- Move/Rename Files and DirectoriesMoves or renames files or directories.
mv oldname.txt newname.txt # Rename file
mv file.txt /path/to/new/location/ # Move file to a different directory
rm
- Remove Files or DirectoriesDeletes files or directories.
rm file.txt # Remove file
rm -r /path/to/directory/ # Remove directory recursively
rm -i file.txt # Prompt before removing
touch
- Create an Empty FileCreates an empty file or updates the timestamp of an existing file.
touch newfile.txt # Create an empty file or update timestamp
mkdir
- Create DirectoriesCreates new directories.
mkdir newdirectory # Create a new directory
mkdir -p /path/to/directory # Create nested directories
cat
- Concatenate and Display FilesDisplays the contents of a file.
cat file.txt # Display file contents
cat file1.txt file2.txt # Display contents of multiple files
less
- View File ContentsViews file contents one screen at a time.
less file.txt # View file with navigation
head
- Display Beginning of FileDisplays the first few lines of a file.
head file.txt # Display the first 10 lines (default)
head -n 20 file.txt # Display the first 20 lines
tail
- Display End of FileDisplays the last few lines of a file.
tail file.txt # Display the last 10 lines (default)
tail -n 20 file.txt # Display the last 20 lines
tail -f logfile.txt # Continuously monitor file for new lines
nano
- Simple Text EditorA simple, user-friendly text editor.
nano file.txt # Open file in nano editor
vim
- Advanced Text EditorA powerful text editor with extensive features.
vim file.txt # Open file in vim editor
uname
- System InformationDisplays system information.
uname -a # Detailed system information
uname -r # Kernel version
df
- Disk Space UsageDisplays disk space usage of file systems.
df -h # Human-readable disk space usage
du
- Disk UsageDisplays disk usage of files and directories.
du -h /path/to/directory # Human-readable disk usage
du -sh /path/to/directory # Summary of disk usage for a directory
top
- Task ManagerDisplays real-time system processes and resource usage.
top # View running processes
ps
- Process StatusDisplays information about active processes.
ps # Snapshot of current processes
ps aux # Detailed list of all processes
htop
- Interactive Process ViewerAn interactive process viewer (similar to top
).
htop # Start htop
ifconfig
- Network Interface ConfigurationDisplays or configures network interfaces (use ip
for newer systems).
ifconfig # Display network interfaces
ip
- IP Address ConfigurationDisplays or configures network interfaces.
ip addr # Display IP addresses
ip link # Display network interfaces
ping
- Check Network ConnectivityTests connectivity to a network host.
ping www.example.com # Ping a domain
ping 192.168.1.1 # Ping an IP address
wget
- Download Files from the WebDownloads files from the internet.
wget http://example.com/file.txt # Download a file
curl
- Transfer Data from or to a ServerTransfers data using various network protocols.
curl http://example.com # Fetch content from URL
curl -O http://example.com/file.txt # Download a file
ssh
- Secure ShellConnects to a remote machine securely.
ssh user@hostname # Connect to remote host
ssh -i keyfile user@hostname # Connect using SSH key
chmod
- Change File PermissionsModifies file or directory permissions.
chmod 755 file.sh # Set read, write, execute for owner; read and execute for group and others
chmod +x file.sh # Add execute permission
chown
- Change File Owner and GroupChanges the ownership of a file or directory.
chown user:group file.txt # Change owner and group
chown user file.txt # Change owner only
sudo apt update # Update package index
sudo apt install package # Install a package
sudo apt upgrade # Upgrade all packages
sudo apt remove package # Remove a package
sudo yum update # Update package index (YUM)
sudo dnf update # Update package index (DNF)
sudo yum install package # Install a package (YUM)
sudo dnf install package # Install a package (DNF)
sudo yum remove package # Remove a package (YUM)
sudo dnf remove package # Remove a package (DNF)
sudo pacman -Syu # Synchronize and update packages
sudo pacman -S package # Install a package
sudo pacman -R package # Remove a package
grep
- Search Text Using PatternsSearches for text patterns within files.
grep "pattern" file.txt # Search for a pattern in a file
grep -r "pattern" /path # Recursive search in a directory
find
- Search for Files and DirectoriesSearches for files and directories.
find /path -name "file.txt" # Find a file by name
find /path -type d # Find directories
tar
- Archive FilesCreates or extracts archives.
tar -cvf archive.tar /path # Create a tar archive
tar -xvf archive.tar # Extract a tar archive
tar -czvf archive.tar.gz /path # Create a compressed archive
tar -xzvf archive.tar.gz # Extract a compressed archive
zip
/unzip
- Compress and Decompress FilesCreates or extracts zip archives.
zip archive.zip file.txt # Create a zip archive
unzip archive.zip # Extract a zip archive
rsync
- Remote File and Directory SynchronizationSynchronizes files and directories between two locations.
rsync -av /source /destination # Synchronize source to destination
rsync -avz /source user@remote:/destination # Synchronize to a remote location
crontab
- Schedule TasksSchedules and manages recurring tasks.
crontab -e # Edit the current user's cron jobs
crontab -l # List the current user's cron jobs
echo
- Display a Line of TextOutputs text to the terminal or to a file.
echo "Hello, World!" # Display text
echo "Text" > file.txt # Write text to a file
echo "More text" >> file.txt # Append text to a file
man
- Manual PagesDisplays the manual page for a command.
man ls # Display manual for the `ls` command
alias
- Create Aliases for CommandsCreates shortcuts for commands.
alias ll='ls -la' # Create an alias for a long listing format
history
- Command HistoryShows the command history.
history # Display command history
!123 # Re-run command number