100 Linux Commands for Every Day Use
5 min readJun 23, 2024
Basic Commands
pwd
– Print the current working directory.
- Example:
pwd
cd
– Change the current directory.
- Example:
cd /home/user
ls
– List directory contents.
- Example:
ls -l
cp
– Copy files or directories.
- Example:
cp file.txt /home/user/backup/
mv
– Move/rename files or directories.
- Example:
mv oldname.txt newname.txt
rm
– Remove files or directories.
- Example:
rm file.txt
mkdir
– Create a new directory.
- Example:
mkdir newdir
rmdir
– Remove an empty directory.
- Example:
rmdir olddir
touch
– Create a new empty file or update the timestamp of an existing file.
- Example:
touch newfile.txt
cat
– Concatenate and display file contents.
- Example:
cat file.txt
File Viewing
less
– View file contents one screen at a time.
- Example:
less file.txt
more
– View file contents one screen at a time (less advanced thanless
).
- Example:
more file.txt
head
– Display the first lines of a file.
- Example:
head -n 10 file.txt
tail
– Display the last lines of a file.
- Example:
tail -n 10 file.txt
nano
– Simple text editor in the terminal.
- Example:
nano file.txt
vim
– Advanced text editor in the terminal.
- Example:
vim file.txt
grep
– Search text using patterns.
- Example:
grep "pattern" file.txt
find
– Search for files in a directory hierarchy.
- Example:
find /home/user -name "*.txt"
diff
– Compare files line by line.
- Example:
diff file1.txt file2.txt
wc
– Word, line, character, and byte count.
- Example:
wc file.txt
File Permissions
chmod
– Change file modes or Access Control Lists.
- Example:
chmod 755 script.sh
chown
– Change file owner and group.
- Example:
chown user:group file.txt
chgrp
– Change group ownership.
- Example:
chgrp group file.txt
File Compression
tar
– Archive files.
- Example:
tar -czvf archive.tar.gz /path/to/dir
zip
– Compress files into a zip archive.
- Example:
zip archive.zip file1 file2
unzip
– Extract files from a zip archive.
- Example:
unzip archive.zip
gzip
– Compress files with gzip.
- Example:
gzip file.txt
gunzip
– Decompress gzip files.
- Example:
gunzip file.txt.gz
bzip2
– Compress files with bzip2.
- Example:
bzip2 file.txt
bunzip2
– Decompress bzip2 files.
- Example:
bunzip2 file.txt.bz2
System Monitoring
top
– Display system tasks.
- Example:
top
htop
– Interactive process viewer.
- Example:
htop
ps
– Report a snapshot of current processes.
- Example:
ps aux
df
– Report file system disk space usage.
- Example:
df -h
du
– Estimate file space usage.
- Example:
du -sh /home/user
free
– Display memory usage.
- Example:
free -h
uptime
– Tell how long the system has been running.
- Example:
uptime
who
– Show who is logged on.
- Example:
who
uname
– Print system information.
- Example:
uname -a
iostat
– Report CPU and I/O statistics.
- Example:
iostat
Networking
ping
– Send ICMP ECHO_REQUEST to network hosts.
- Example:
ping google.com
ifconfig
– Configure a network interface.
- Example:
ifconfig eth0
ip
– Show/manipulate routing, devices, policy routing, and tunnels.
- Example:
ip addr show
netstat
– Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
- Example:
netstat -tuln
ss
– Another utility to investigate sockets.
- Example:
ss -tuln
wget
– Non-interactive network downloader.
- Example:
wget http://example.com/file.zip
curl
– Transfer data from or to a server.
- Example:
curl -O http://example.com/file.zip
scp
– Secure copy (remote file copy program).
- Example:
scp file.txt user@remote:/path/to/dest/
ssh
– OpenSSH SSH client (remote login program).
- Example:
ssh user@remote
ftp
– File Transfer Protocol client.
- Example:
ftp ftp.example.com
Disk Management
fdisk
– Partition table manipulator for Linux.
- Example:
fdisk /dev/sda
mkfs
– Build a Linux file system.
- Example:
mkfs.ext4 /dev/sda1
mount
– Mount a file system.
- Example:
mount /dev/sda1 /mnt
umount
– Unmount a file system.
- Example:
umount /mnt
fsck
– File system consistency check and repair.
- Example:
fsck /dev/sda1
User Management
useradd
– Create a new user.
- Example:
useradd newuser
userdel
– Delete a user account and related files.
- Example:
userdel newuser
usermod
– Modify a user account.
- Example:
usermod -aG sudo newuser
passwd
– Update a user’s authentication tokens.
- Example:
passwd newuser
groupadd
– Create a new group.
- Example:
groupadd newgroup
Package Management (Debian/Ubuntu)
apt-get
– APT package handling utility.
- Example:
apt-get update
apt-cache
– Query the APT cache.
- Example:
apt-cache search package
dpkg
– Debian package manager.
- Example:
dpkg -i package.deb
aptitude
– High-level interface to the package manager.
- Example:
aptitude install package
Package Management (Red Hat/CentOS)
yum
– Package manager for RPM-based distributions.
- Example:
yum install package
rpm
– RPM package manager.
- Example:
rpm -ivh package.rpm
dnf
– Modernized package manager for RPM-based distributions.
- Example:
dnf install package
System Control
systemctl
– Control the systemd system and service manager.
- Example:
systemctl start service
service
– Run a System V init script.
- Example:
service service start
shutdown
– Halt, power-off or reboot the machine.
- Example:
shutdown -h now
reboot
– Reboot the system.
- Example:
reboot
halt
– Halt the system.
- Example:
halt
init
– Change runlevel.
- Example:
init 0
Archive and Backup
rsync
– Remote file and directory synchronization.
- Example:
rsync -av /source /destination
dd
– Convert and copy a file.
- Example:
dd if=/dev/sda of=/dev/sdb
Text Processing
awk
– Pattern scanning and processing language.
- Example:
awk '{print $1}' file.txt
sed
– Stream editor for filtering and transforming text.
- Example:
sed 's/old/new/g' file.txt
cut
– Remove sections from each line of files.
- Example:
cut -d' ' -f1 file.txt
sort
– Sort lines of text files.
- Example:
sort file.txt
uniq
– Report or omit repeated lines.
- Example:
uniq file.txt
tr
– Translate or delete characters.
- Example:
tr 'a-z' 'A-Z' < file.txt
paste
– Merge lines of files.
- Example:
paste file1.txt file2.txt
join
– Join lines of two files on a common field.
- Example:
join file1.txt file2.txt
tee
– Read from standard input and write to standard output and files.
- Example:
echo "Hello" | tee file.txt
Disk Usage
lsblk
– List information about block devices.
- Example:
lsblk
blkid
– Locate/print block device attributes.
- Example:
blkid
df
– Report file system disk space usage.
- Example:
df -h
System Logs
dmesg
– Print or control the kernel ring buffer.
- Example:
dmesg
journalctl
– Query and display messages from the journal.
- Example:
journalctl -xe
Miscellaneous
alias
– Create an alias for a command.
- Example:
alias ll='ls -l'
unalias
– Remove an alias.
- Example:
unalias ll
env
– Run a program in a modified environment.
- Example:
env VAR=value command
printenv
– Print all or part of environment.
- Example:
printenv PATH
export
– Set an environment variable.
- Example:
export PATH=/usr/local/bin:$PATH
date
– Display or set the system date and time.
- Example:
date "+%Y-%m-%d %H:%M:%S"
cal
– Display a calendar.
- Example:
cal
whoami
– Print effective user ID.
- Example:
whoami
hostname
– Show or set the system’s hostname.
- Example:
hostname
clear
– Clear the terminal screen.
- Example:
clear
history
– Show the command history. – Example:history