1. File and Directory Navigation
| Command | Description | Example |
|---|
pwd | Displays the current working directory. | pwd → /home/user/Documents |
ls | Lists files and directories in the current location. | ls |
ls -l | Lists files with detailed info (permissions, size, date, owner). | ls -l |
cd [directory] | Changes the current directory. | cd /etc |
cd .. | Moves up one level in the directory structure. | cd .. |
cd / | Goes to the root directory. | cd / |
2. File Management
| Command | Description | Example |
|---|
touch [file] | Creates an empty file. | touch notes.txt |
cp [source] [destination] | Copies files or directories. | cp file.txt /backup/ |
mv [source] [destination] | Moves or renames files/directories. | mv old.txt new.txt |
rm [file] | Deletes a file. | rm temp.txt |
rm -r [directory] | Deletes a directory and all its contents. | rm -r old_folder/ |
3. Text Manipulation
| Command | Description | Example |
|---|
cat [file] | Displays the content of a file. | cat readme.txt |
less [file] | Opens a file for paginated viewing (scroll up/down). | less /etc/passwd |
head [file] | Shows the first 10 lines. | head log.txt |
tail [file] | Shows the last 10 lines. | tail log.txt |
grep "text" [file] | Searches for a specific word or phrase inside a file. | grep "error" log.txt |
4. Permissions and Ownership
| Command | Description | Example |
|---|
chmod [permissions] [file] | Changes file permissions using numeric or symbolic mode. | chmod 755 script.sh |
chown [user:group] [file] | Changes file owner and group. | chown root:root config.txt |
5. Process Management
| Command | Description | Example |
|---|
ps | Displays running processes. | ps aux |
top | Real-time view of system processes and usage. | top |
kill [PID] | Terminates a process by its ID. | kill 1234 |
killall [name] | Kills all processes with a given name. | killall firefox |
6. User and Group Management
| Command | Description | Example |
|---|
whoami | Displays the current logged-in user. | whoami |
who | Lists all users currently connected. | who |
adduser [user] | Creates a new user account. | sudo adduser alice |
deluser [user] | Deletes a user account. | sudo deluser bob |
passwd [user] | Changes a user’s password. | sudo passwd alice |
7. Networking
| Command | Description | Example |
|---|
ping [host] | Tests network connectivity. | ping google.com |
ifconfig / ip a | Shows network interfaces and IP addresses. | ip a |
netstat -tulnp | Displays open ports and listening services. | sudo netstat -tulnp |
wget [URL] | Downloads a file from the web. | wget https://example.com/file.zip |
curl [URL] | Displays or transfers data from a URL. | curl https://api.github.com |
8. Package Management
-Debian / Ubuntu (APT)
| Command | Description | Example |
|---|
apt update | Updates the package list. | sudo apt update |
apt upgrade | Upgrades all installed packages. | sudo apt upgrade |
apt install [package] | Installs a package. | sudo apt install vim |
apt remove [package] | Removes a package. | sudo apt remove nano |
–RedHat / CentOS (YUM)
| Command | Description | Example |
|---|
yum update | Updates packages. | sudo yum update |
yum install [package] | Installs a package. | sudo yum install git |
yum remove [package] | Removes a package. | sudo yum remove httpd |
9. Compression and Archiving
| Command | Description | Example |
|---|
tar -cvf file.tar [files] | Creates a tar archive. | tar -cvf backup.tar /home/user/ |
tar -xvf file.tar | Extracts a tar archive. | tar -xvf backup.tar |
gzip [file] | Compresses a file using gzip. | gzip notes.txt |
gunzip [file.gz] | Decompresses a gzip file. | gunzip notes.txt.gz |
zip [file.zip] [files] | Creates a ZIP file. | zip archive.zip *.txt |
unzip [file.zip] | Extracts a ZIP archive. | unzip archive.zip |
10. Other Useful Utilities
| Command | Description | Example |
|---|
clear | Clears the terminal screen. | clear |
history | Shows previously used commands. | history |
echo "text" | Displays text or variables. | echo $USER |
date | Displays the current date and time. | date |
shutdown -h now | Shuts down the system immediately. | sudo shutdown -h now |
reboot | Restarts the system. | sudo reboot |
Deixa un comentari