Common Linux Commands and Descriptions
Linux FileSystem Structure
/
βββ bin/ # Essential user binaries (e.g., ls, cat), accessible by all users.
βββ boot/ # Files needed to boot the system, like the kernel and bootloader configs.
βββ dev/ # Device files representing hardware (e.g., /dev/sda for hard drives).
βββ etc/ # System-wide configuration files (e.g., fstab, hosts).
β βββ init.d/ # Service scripts (start, stop, restart)
β βββ nginx/ # Configuration for the nginx web server
β βββ ssh/ # SSH configuration files
βββ home/ # User home directories for personal data.
β βββ user/ # Directory for user 'user',
βββ lib/ # Shared libraries essential for the system and kernel modules.
βββ media/ # Mount points for removable media, external devices like USBs or DVDs.
βββ mnt/ # Temporary mount directory
βββ opt/ # Optional software packages or third-party apps.
βββ proc/ # Process and kernel information
βββ root/ # Home directory for root user
βββ sbin/ # System binaries for administrative tasks (e.g., reboot, iptables).
βββ tmp/ # Temporary files, often cleared on reboot.
βββ usr/ # User programs and libraries, typically for installed packages.
β βββ bin/ # User commands
β βββ lib/ # User libraries
β βββ share/ # Shared files
βββ var/ # Variable files (logs, databases, etc.)
βββ log/ # Log files
βββ cache/ # Application cache data
βββ tmp/ # Temporary files created by applications
File and Directory Operations
-
lsβ Lists the contents of a directory.
ls ls -l # Long listing format ls -a # List all files, including hidden ones -
cdβ Changes the current directory.
cd /path/to/directory cd .. # Go up one directory cd ~ # Go to the home directory -
mkdirβ Creates a new directory.
mkdir new_directory -
rmdirβ Removes an empty directory.
rmdir directory_name -
cpβ Copies files or directories.
cp source_file destination cp -r source_directory destination_directory # Copy directories recursively -
mvβ Moves or renames files and directories.
mv old_name new_name mv file_name /path/to/destination/ -
rmβ Removes files or directories.
rm file_name rm -r directory_name # Remove directories recursively -
touchβ Creates an empty file or updates the timestamp of an existing file.
touch file_name
File Viewing & Manipulation
-
catβ Displays the contents of a file.
cat file_name -
lessβ Allows you to view file contents page by page.
less file_name -
headβ Shows the first 10 lines of a file (default).
head file_name head -n 5 file_name # Show the first 5 lines -
tailβ Shows the last 10 lines of a file (default).
tail file_name tail -n 5 file_name # Show the last 5 lines -
grepβ Searches for patterns within files.
grep 'search_term' file_name grep -r 'search_term' /path/to/directory # Search recursively in directories
Permissions & Ownership
-
chmodβ Changes file permissions.
chmod 755 file_name # Gives read, write, execute permissions to the owner and read, execute to others chmod +x script.sh # Make file executable -
chownβ Changes the file owner and group.
chown user:group file_name -
umaskβ Sets default file creation permissions.
umask 022 # Sets default permissions to 755 for directories and 644 for files
Process Management
-
psβ Displays the currently running processes.
ps ps aux # Show all processes -
topβ Displays real-time system processes and resource usage.
top -
killβ Terminates a process by its PID.
kill process_id kill -9 process_id # Forcefully kill a process -
htopβ Interactive process viewer (requires installation).
htop
System Information
-
dfβ Shows disk space usage.
df -h # Human-readable format -
duβ Shows disk usage for files and directories.
du -h /path/to/directory -
freeβ Displays memory usage.
free -h # Human-readable format -
unameβ Shows system information.
uname -a # Display all system info -
uptimeβ Shows how long the system has been running.
uptime -
whoamiβ Displays the current logged-in user.
whoami -
hostnameβ Displays or sets the system's hostname.
hostname -
lscpuβ Displays CPU architecture information.
lscpu
Network Commands
-
pingβ Tests connectivity to a host.
ping google.com -
ifconfigβ Displays network interface information (may require net-tools installation on some systems).
ifconfig -
ipβ Configures network interfaces and routing.
ip addr show # Show IP addresses of network interfaces ip route show # Show routing table -
curlβ Fetches data from a URL.
curl https://example.com -
wgetβ Downloads files from the web.
wget https://example.com/file.zip
Package Management
-
apt-get(for Debian/Ubuntu-based distributions) β Installs, updates, or removes software packages.
sudo apt-get update # Update package list sudo apt-get install package # Install a package sudo apt-get remove package # Remove a package -
yum(for RedHat/CentOS-based distributions) β Installs, updates, or removes software packages.
sudo yum update # Update package list sudo yum install package # Install a package sudo yum remove package # Remove a package
File Compression
-
tarβ Archives or extracts files.
tar -czvf archive_name.tar.gz /path/to/directory # Create a compressed archive tar -xzvf archive_name.tar.gz # Extract a compressed archive -
zipβ Compresses files into a zip archive.
zip archive_name.zip file1 file2 -
unzipβ Extracts a zip archive.
unzip archive_name.zip
Miscellaneous
-
echoβ Prints a message or variables to the terminal.
echo "Hello, World!" -
dateβ Displays or sets the system date and time.
date -
aliasβ Creates an alias for a command.
alias ll='ls -la' # Create a shortcut for 'ls -la' -
historyβ Shows the command history.
history -
clearβ Clears the terminal screen.
clear
These are just a few of the many powerful commands in Linux, but they cover most of the common operations you'll perform daily.
If you found this helpful, let me know by leaving a π or a comment!, or if you think this post could help someone, feel free to share it! Thank you very much! π
Top comments (0)