Linux

 

cd —change the working directory
cd ~ — go to home directory
cd .. — move up one level of your directory
cd - — go to previous directory
ls — list the content of a directory
pwd — shows your current working directory
rm and rmdir — remove a file or directory
cp — copy a file or directory
mv — move a file or directory
File and Directory Commands
Command Description Example
ls   List directory contents.
cd   Change directory. cd /path/to/directory
pwd   Show current directory. pwd
mkdir   Create a new directory. mkdir new_directory
rmdir   Remove an empty directory. rmdir empty_directory
rm   Delete files or directories. rm file.txt
touch   Create an empty file. touch new_file.txt
cp   Copy files or directories. cp file.txt /path/to/destination
mv   Move or rename files. mv file.txt /path/to/new_location
cat   Display file contents. cat file.txt
nano/vim  Edit files in terminal. nano file.txt
find   Search for files in a directory hierarchy. find . -name "file.txt"
grep   Search text using patterns. grep "pattern" file.txt
tar   Archive and compress files. tar -cvf archive.tar file1.txt file2.txt
df   Show disk usage of file systems. df
du   Show directory/file size. du -sh /path/to/directory
chmod   Change file permissions. chmod 755 file.txt
chown   Change file owner. chown user:group file.txt
mount   Mount a filesystem. mount /dev/sdb1 /mnt
umount   Unmount a filesystem. umount /mnt
Networking Commands
Command Description Sample Usage
ping  Test connectivity to a host. ping google.com
ifconfig / ip a  Display network interfaces. ifconfig or ip a
netstat / ss  Show network connections. netstat -tuln or ss -tuln
wget  Download files via HTTP/FTP. wget http://example.com/file.zip
curl  Transfer data using URL syntax. curl -O http://example.com/file.zip
nc (Netcat)  Network debugging and data transfer. nc -zv 192.168.1.1 80
tcpdump  Capture and analyze network packets. tcpdump -i eth0
iptables  Configure firewall rules. iptables -A INPUT -p tcp --dport 22 -j ACCEPT
traceroute  Trace the path packets take to a network host. traceroute example.com
nslookup  Query DNS to obtain domain name or IP address mapping. nslookup example.com
ssh  Securely connect to a remote host. ssh user@example.com
Process and System Monitoring Commands
Command Description Example Command
ps  Show running processes. ps aux
top  Dynamic process viewer. top
htop  Enhanced version of top. htop
kill  Send a signal to a process. kill
killall  Kill processes by name. killall
uptime  System uptime and load. uptime
whoami  Current logged-in user. whoami
env  Display environment variables. env
strace  Trace system calls of a process. strace -p
systemctl  Manage systemd services. systemctl status
journalctl  View system logs. journalctl -xe
free  Display memory usage. free -h
vmstat  Report virtual memory statistics. vmstat 1
iostat  Report CPU and I/O statistics. iostat
lsof  List open files by processes. lsof
dmesg  Print kernel ring buffer messages. dmesg
User and Permission Management Commands
Command Description Example Command
passwd  Change user password. passwd
adduser / useradd  Add a new user. adduser or useradd
deluser / userdel  Delete a user. deluser or userdel
usermod  Modify user account. usermod -aG
groups  Show group memberships. groups
sudo  Execute commands as root. sudo
chage  Change user password expiry information. chage -l
id  Display user identity information. id
newgrp  Log in to a new group. newgrp
File Transfer and Synchronization Commands
Command Description Example Command
scp  Securely copy files over SSH. scp user@remote:/path/to/file /local/destination
rsync  Efficiently sync files and directories. rsync -avz /local/directory/ user@remote:/path/to/destination
ftp  Transfer files using the File Transfer Protocol. ftp ftp.example.com
sftp  Securely transfer files using SSH File Transfer Protocol. sftp user@remote:/path/to/file
wget  Download files from the web. wget http://example.com/file.zip
curl  Transfer data from or to a server. curl -O http://example.com/file.zip

Text Processing Commands
Command Description Example Command
awk  Pattern scanning and processing. awk '{print $1}' file.txt
sed  Stream editor for filtering/modifying text. sed 's/old/new/g' file.txt
cut  Remove sections from lines of text. cut -d':' -f1 /etc/passwd
sort  Sort lines of text. sort file.txt
grep  Search for patterns in text. grep 'pattern' file.txt
wc  Count words, lines, and characters. wc -l file.txt
paste  Merge lines of files. paste file1.txt file2.txt
join  Join lines of two files on a common field. join file1.txt file2.txt
head  Output the first part of files. head -n 10 file.txt
tail  Output the last part of files. tail -n 10 file.txt
Shell   Utilities and Shortcuts Commands
Command Description Example Command
alias  Create shortcuts for commands. alias ll='ls -la'
unalias  Remove an alias. unalias ll
history  Show previously entered commands. history
clear  Clear the terminal screen. clear
reboot  Reboot the system. reboot
shutdown  Power off the system. shutdown now
date  Display or set the system date and time. date
echo  Display a line of text. echo "Hello, World!"
sleep  Delay for a specified amount of time. sleep 5
time  Measure the duration of command execution. time ls
watch  Execute a program periodically, showing output fullscreen. watch -n 5 df -h

Comments

Popular posts from this blog

journals