diff
: To find the differences between two files, usediff
followed by the file names. For example,diff file1.txt file2.txt
will display the lines that differ between “file1.txt” and “file2.txt”.cmp
: Usecmp
followed by the two file names to check if two files are identical. If there is no output, it means the files are the same. For example,cmp file1.txt file2.txt
.comm
:comm
compares two sorted files line by line and displays lines that are common or unique between the files. Usecomm
followed by the file names. For example,comm file1.txt file2.txt
.sort
: To sort the content of a file, usesort
followed by the file name. It will display the sorted output. For example,sort myfile.txt
.export
: To set environment variables, useexport
followed by the variable name and value. For example,export MY_VAR="Hello"
.zip
: Usezip
followed by the archive name and the files/directories you want to zip. For example,zip archive.zip file1.txt file2.txt
will create a zip archive containing “file1.txt” and “file2.txt”.unzip
: To extract files from a zip archive, useunzip
followed by the archive name. For example,unzip archive.zip
.ssh
: Usessh
followed by the username and the remote host to establish a secure shell connection. For example,ssh username@remote_host
.service
: To start or stop services in Linux, useservice
followed by the service name and the action (start, stop, restart, etc.). For example,service apache2 start
will start the Apache service.ps
: Useps
to display active processes. The commandps aux
shows a detailed list of all processes running on the system.kill
andkillall
: To terminate a process, usekill
followed by the process ID (PID). For example,kill 1234
.killall
allows you to terminate processes by name. For example,killall firefox
will terminate all Firefox processes.df
: Typingdf
displays disk usage and filesystem information.mount
: Usemount
to mount file systems in Linux. Provide the device or file system and the mount point. For example,mount /dev/sdb1 /mnt
will mount the device/dev/sdb1
to the/mnt
directory.chmod
: To change file permissions, usechmod
followed by the desired permission settings and the file/directory. For example,chmod 755 myfile.txt
sets read, write, and execute permissions for the owner, and read and execute permissions for group and others.chown
: Usechown
followed by the new owner and the file/directory to change ownership. For example,chown newuser myfile.txt
changes the owner of “myfile.txt” to “newuser”.ifconfig
: Typingifconfig
displays network interfaces and their associated IP addresses.traceroute
: Usetraceroute
followed by the destination IP or domain name to trace the network hops to reach the destination. For example,traceroute google.com
will show the network path to reach Google’s servers.wget
: To download files from the internet, usewget
followed by the URL of the file you want to download. For example,wget https://example.com/file.txt
will download “file.txt” from the given URL.ufw
:ufw
is the uncomplicated firewall command in Linux. You can use it to manage the firewall rules. For example,ufw allow 22
allows incoming SSH connections on port 22.iptables
:iptables
is the base firewall utility that provides more advanced configuration options for the firewall. It allows you to define specific firewall rules and policies.apt
,pacman
,yum
,rpm
: These are package managers used in different Linux distributions. You can use these commands to install, update, or remove software packages. The usage may vary depending on the specific distribution you are using.sudo
: To escalate privileges in Linux and execute commands with administrative privileges, prefix the command withsudo
. For example,sudo apt-get update
will update the package list using elevated privileges.cal
: Typingcal
will display a command-line calendar for the current month.alias
: To create custom shortcuts for regularly used commands, usealias
followed by the desired alias name and the command you want to associate with it. For example,alias ll='ls -l'
creates an alias “ll” for the commandls -l
.dd
:dd
is used for low-level copying and conversion of data. To create a bootable USB stick, you can usedd
to copy the ISO image to the USB device. For example,dd if=image.iso of=/dev/sdb bs=4M
will copy the “image.iso” file to the USB device/dev/sdb
.whereis
: Usewhereis
followed by the command name to locate the binary, source code, and manual pages for a command. For example,whereis ls
will display the location of the “ls” command.whatis
: To find a brief description of what a command is used for, usewhatis
followed by the command name. For example,whatis ls
will provide a short description of the “ls” command.top
: Typingtop
displays a live view of active processes, system usage, and resource statistics.useradd
andusermod
: To add a new user, useuseradd
followed by the username. For example,useradd newuser
creates a new user with the username “newuser”.usermod
is used to modify existing user accounts.passwd
: To create or update passwords for existing users, usepasswd
followed by the username. For example,passwd username
will prompt you to enter a new password for the specified user.
Second post how to use them
|
Aug 17, 2024
min read