Introduction
We are going to see 100 linux useful commands, that may be handy in case of any trouble shooting or user/admin related activities
ls – List the contents of a directory
# ls
cd – Change the current directory
# cd Documents
mkdir – Create a new directory
mkdir my_directory
mv – Move or rename a file or directory
# mv old_file.txt new_file.txt
cp – Copy a file or directory# cp file1.txt file2.txt
cp file1.txt file2.txt
rm – Remove a file or directory
rm file.txt
chmod – Change the permissions of a file or directory
chmod 755 file.txt
grep – Search for a string in a file
grep "string" file.txt
find – Search for files in a directory
find . -name "*.txt"
cat – Display the contents of a file
cat file.txt
head – Display the first few lines of a file
head -n 5 file.txt
tail – Display the last few lines of a file
tail -n 5 file.txt
sort – Sort the contents of a file
sort file.txt
uniq – Remove duplicate lines from a file
uniq file.txt
tar – Create an archive file
tar -cvf archive.tar file1.txt file2.txt
gzip – Compress a file
gzip file.txt
gunzip – Decompress a file
gunzip file.txt.gz
ssh – Connect to a remote computer
ssh user@host
scp – Copy files between computers
scp file.txt user@host:~/
ping – Test the connection to a remote computer
ping www.example.com
ifconfig – Display network configuration
ifconfig
route – Display the routing table
route -n
netstat – Display network connections
netstat -an
top – Display the top running processes
top
ps – Display the running processes
ps -ef
kill – Terminate a process
kill -9 1234
df – Display disk usage
df -h
du – Display disk usage of a directory
du -sh /home/user
free – Display memory usage
free -m
wget – Download a file from the internet
wget http://example.com/file.zip
curl – Download a file from the internet
curl -O http://example.com/file.zip
apt-get – Install a package
apt-get install package
yum – Install a package
yum install package
systemctl – Manage system services
systemctl start service
service – Manage system services
service service start
reboot – Reboot the system
reboot
shutdown – Shutdown the system
shutdown -h now
date – Display the current date and time
date
cal – Display a calendar
cal
whoami – Display the current user
whoami
passwd – Change the current user’s password
passwd
su – Switch to another user
su user
sudo – Execute a command as another user
sudo command
vi – Edit a file
vi file.txt
nano – Edit a file
nano file.txt
grep – Search for a string in a file
grep "string" file.txt
awk – Process text
awk '{print $1}' file.txt
sed – Process text
sed 's/old/new/g' file.txt
tr – Translate characters
tr '[a-z]' '[A-Z]' < file.txt
diff – Compare two files
diff file1.txt file2.txt
patch – Apply a patch to a file
patch file.txt patch.diff
ln – Create a symbolic link
ln -s file.txt link.txt
chown – Change the owner of a file
chown user file.txt
chgrp – Change the group of a file
chgrp group file.txt
touch – Create an empty file
touch file.txt
echo – Print a string
echo "Hello World"
printf – Print a formatted string
printf "Hello %s\n" World
bc – Perform calculations
echo "2+2" | bc
history – Display the command history
history
man – Display the manual page for a command
man ls
which – Display the path of a command
which ls
type – Display the type of a command
type ls
alias – Create an alias for a command
alias ll='ls -l'
unalias – Remove an alias
unalias ll
export – Set an environment variable
export PATH=$PATH:/usr/local/bin
env – Display the environment variables
env
echo – Display the value of an environment variable
echo $PATH
source – Execute a script in the current shell
source script.sh
ssh-keygen – Generate an SSH key
ssh-keygen -t rsa -b 4096
ssh-copy-id – Copy an SSH key to a remote computer
ssh-copy-id user@host
rsync – Synchronize files between computers
rsync -avz user@host:/home/user/ ~/
nc – Network connection tool
nc -l -p 8080
telnet – Connect to a remote computer
telnet host 80
w – Display who is logged in
w
uptime – Display the system uptime
uptime
last – Display the last logged in users
last
lsof – List open files
lsof -i
netcat – Network connection tool
nc -l -p 8080
iptables – Configure the firewall
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
dig – Query DNS
dig example.com
nslookup – Query DNS
nslookup example.com
host – Query DNS
host example.com
traceroute – Trace the route to a remote host
traceroute example.com
nmap – Scan a network
nmap -sV example.com
tmux – Multiplex terminal sessions
tmux
screen – Multiplex terminal sessions
screen
nohup – Run a command in the background
nohup command &
crontab – Schedule a command to run periodically
crontab -e
at – Schedule a command to run once
at now + 1 hour
watch – Execute a command periodically
watch -n 10 ls
dd – Copy a file
dd if=file.txt of=file.bak
tee – Redirect output to multiple files
ls | tee file1.txt file2.txt
ntpd – Synchronize the system clock
ntpd -q
logrotate – Rotate log files
logrotate -f /etc/logrotate.conf
rdate – Synchronize the system clock
rdate -s time.example.com
ntpdate – Synchronize the system clock
ntpdate -u time.example.com
chkconfig – Manage system services
chkconfig --list
system-config-services – Manage system services
system-config-services
iwconfig – Configure wireless network
iwconfig wlan0 essid "My Network"
iwlist – Scan for wireless networks
iwlist wlan0 scan
Conclusion
There are lot more commands in linux, this is just basics people who are looking for basic commands quick through, let us know your thoughts and inputs
Aslo read:
Veritas Volume Manager (VxVM) cheatsheet – https://computercarriage.com/2023/03/02/veritas-volume-manager-vxvm-cheatsheet/
Troubleshooting commands in Linux – https://computercarriage.com/2023/02/16/troubleshooting-commands-in-linux/
block devices using lsblk – https://computercarriage.com/2020/05/18/list-block-devices-using-lsblk-command/
tldp.org – https://tldp.org/LDP/abs/html/basic.html