translations: [ es/Español ] · [ fr/Français ] · [ de/Deutsch ]
Table of contents
Enhance your Linux system management with these essential commands:
View and Navigate File System with ls
List files and directories in the current location.
ls
ls -l
ls -a
ls -lh
ls -R
Manipulate Files and Directories with cp
Copy files or directories to desired locations.
cp file.txt new_location/
cp -r directory/ new_location/
cp -a directory/ new_location
cp -u file1.txt file2.txt destination_folder/
Manipulate Files and Directories with mv
Move or rename files and directories.
mv file.txt new_location/
mv directory/ new_location/
mv old_name.txt new_name.txt
mv file.txt ../new_directory/
Manage File Permissions with chmod
Modify file permissions for enhanced security.
chmod +x script.sh
chmod 644 file.txt
chmod -R 777 directory/
chmod 755 folder/
Display System Information with uname
Retrieve system information.
uname -a
uname -r
uname -m
Archive Compression using tar
Compress and decompress files and directories.
tar -czvf archive.tar.gz directory/
tar -xzvf archive.tar.gz
tar -cvf archive.tar file1 file2
View Current Date and Time with date
Display or set the system date and time.
date
date "+%Y-%m-%d %H:%M:%S"
date -d "yesterday"
Manipulate File Contents with sed
Stream editor for text transformation.
sed 's/old/new/g' file.txt
sed -i 's/old/new/g' file.txt
sed -n '1,5p' file.txt
Compare Files with diff
Compare files line by line.
diff file1.txt file2.txt
diff -u file1.txt file2.txt
diff -r directory1/ directory2/
Create Empty Files or Update Timestamp with touch
Create empty files or update access/modify timestamps.
touch new_file.txt
touch -d "last Monday" file.txt
touch -r file1.txt file2.txt
Display Disk Usage with df
Display disk space usage of file systems.
df
df -h
df -i
Display Running Processes with ps
Display currently running processes.
ps
ps aux
ps -ef
Manage User Information with who
Display information about logged-in users.
who
whoami
who -a
Check File Type with file
Determine file type.
file filename
file -i filename
file -s filename
Monitor System Processes with top
Monitor system processes and resource usage.
top
top -u username
top -n 1
Redirect Output to Files with tee
Redirect command output to files and terminal.
ls -l | tee output.txt
cat file.txt | tee -a output.txt
View System Information with hostname
Display or set the system’s hostname.
hostname
hostname -I
hostnamectl
Create Pipes Between Commands with |
(Pipe)
Redirect output of one command as input to another.
ls -l | grep "keyword"
cat file.txt | sed 's/old/new/g'
Display File System Structure with tree
Display directory structure in a tree-like format.
tree
tree directory/
tree -L 2
Search File Contents with grep
Search for patterns in files.
grep "pattern" file.txt
grep -r "pattern" directory/
grep -i "pattern" file.txt
Master these commands to efficiently manage your Linux system!
Created on: Dec 29, 2023
Last updated on: Jan 7, 2024
Discover More within this Subject:
- Understanding `kill` Command in Linux
- Understanding `ps` Command in Linux
- Converting Audio Files Using Sox
- Understanding and using Dnf in Fedora
- Upgrading and Rolling Back Fedora Silverbue