Home » kali Linux » Linux Commands Everything you need to know

Linux Commands Everything you need to know

Linux is an open-source operating system that has been used by millions of people worldwide. In this article, I’ll teach you some basic Linux commands so you can start using it today!

Basic Linux Commands

CommandDescription
hostnamectlGet system information including, operating system, kernel, and release version
dateDisplay the current system date and time
hostnameDisplay the hostname of the system
ifconfigDisplay the IP and Mac Address of the system
wDisplay currently logged in users in the system
free -mDisplay free and used memory in the system
topDisplay all running processes
lsList all files and directories in the current working directory
ls -alList all files and directories including, hidden files and other information like permissions, size, and owner
cdChange the directory to the home directory
cd ..Change the directory to one level up
cat filenameDisplay the content of the file
cat file1 file2 > file3Combine two files named file1 and file2 and store the output in a new file file3
tail filenameDisplay the last 10 lines of a file
head filenameDisplay the first 10 lines of a file
mv oldfile newfileRename a file
rm filenameDelete a file
mkdir dirnameCreate a directory
rm -rf dirnameRemove a directory
historyPrint a history list of all commands
clearClear the terminal
shutdown -h nowShut down the system
rebootRestart the system

Networking Linux Commands

CommandDescription
ip addr show Or ifconfigList all IP addresses and network interfaces
ip addr add IP-Address dev eth1Add a temporary IP address to interface eth1
netstat -pnltuDisplay all listening port
whois domainnameDisplay more information about any domain
dig domainnameDisplay DNS information of any domain
host domainnamePerform an IP lookup for a domain
dig -x IP-AddressPerform a reverse lookup of an IP address
dig -x domainamePerform a reverse lookup on domain
ping host-ipCheck connectivity between two hosts

File Permission Linux Commands

CommandDescription
ls -l filenameCheck the current permission of any file
chmod 777 filenameAssign full(read, write, and execute) permission to everyone
chmod -R 777 dirnameAssign full permission to the directory and all sub-directories
chmod 766 filenameAssign full permission to the owner, and read and write permission to group and others
chmod -x filenameRemove the execution permission of any file
chown username filenameChange the ownership of a file
chown user:group filenameChange the owner and group ownership of a file
chown -R user:group dirnameChange the owner and group ownership of the directory and all sub-directories

Linux User and Group Management Commands

CommandDescription
wDisplay all login users
useradd usernameAdd a new user account
userdel -r usernameDelete a user account
usermod [option] usernameChange the user account information including, group, home directory, shell, expiration date
usermod -aG groupname usernameAdd a user to a specific group
groupadd groupnameCreate a new group
groupdel groupnameRemove a group
lastDisplay information of the last login user
idDisplay UID and GID of the current user

Linux Process Management Commands

CommandDescription
psDisplay all active processes
ps -ef | grep processnameDisplay information of specific process
topManage and display all processes in realtime
pstreeDisplay processes in the tree-like diagram
lsofList all files opened by running processes
kill pidKill a specific process using process ID
killall processnameKill all processes by name
bgDisplay stopped or background jobs
pidof processnameGet the PID of any process

Linux Hard Drive and Storage Commands

CommandDescription
df or df -hSee the current storage usage of mounted partitions
sudo fdisk -lSee information for all attached storage devices
duSee disk usage of a directory’s contents
treeView the directory structure for a path
mount and umountMount and unmount a storage device or ISO file

Linux Disk Management Commands

CommandDescription
fdisk -lList all disk partitions
fdisk /dev/sdaCreate a new partition on /dev/sda device
mkfs.ext4 /dev/sda1Format the partition named /dev/sda1
fsck.ext4 /dev/sda1Check and repair a filesystem for any error
mount /dev/sda1 /mntMount any partition to any directory
df -hDisplay free space of mounted file system
df -iDisplay free inodes on the filesystem
du -hsDisplay the size of your current directory
lsblkDisplay information about block devices
lsusb -tvDisplay all USB devices
hdparm -tT /dev/sdaPerform a read speed test on disk /dev/sda
badblocks -s /dev/sdaTest for unreadable blocks on disk /dev/sda

Linux Package Management Command

CommandDescription
apt-get install packagenameInstall the package on Debian based distributions
apt-get remove packagenameRemove a package on Debian based distributions
dpkg -l | grep -i installedGet a list of all packages on Debian based distributions
dpkg -i packagename.debInstall .deb package
apt-get updateUpdate the repository on Debian based distributions
apt-get upgrade packagenameUpgrade a specific package on Debian based distributions
apt-get autoremoveRemove all unwanted packages on Debian based distributions
yum install packagenameInstall the package on RPM-based distributions
yum remove packagenameRemove a package on RPM-based distributions
yum updateUpdate all system packages to the latest version on RPM-based distributions
yum list --installedList all installed packages on RPM-based distributions
yum list --availableList all available packages on RPM-based distributions

Linux Compress and Uncompressed Commands

CommandDescription
tar -cvf filename.tar filenameCompress a file in the Tar archive
tar -xvf filename.tarUncompress a Tar file
tar -tvf filename.tarList the content of the Tar file
tar -xvf filename.tar file1.txtUntar a single file from Tar file
tar -rvf filename.tar file2.txtAdd a file to the Tar file
zip filename.zip filenameCompress a single file to a zip
zip filename.zip file1.txt file2.txt file3.txtCompress multiple files to a zip
zip -u filename.zip file4.txtAdd a file to a zip file
zip -d filename.zip file4.txtDelete a file from a zip file
unzip -l filename.zipDisplay the content of zip archive file
unzip filename.zipUnzip a file
unzip filename.zip -d /dirnameUnzip a file to a specific directory

Linux Kernel Information and Module Management

CommandDescription
uname -aOutput detailed information about your kernel version and architecture
lsmodFind what modules are currently loaded
modinfo module_nameGet information about any particular module
modprobe --remove module_nameRemove a module
modprobe module_nameLoad a module into the kernel

Environment Variable Commands

CommandDescription
printenv or printenv variable_nameList all environment variables on a Linux system, or a specific one
whereis and whichFind where a command in PATH is located
export MY_SITE="linuxconfig.org"Set a temporary environment variable (just an example, but use the same syntax)
echo $VARIABLEDisplay the value of a variable
unsetRemove a variable

Hardware Information Commands

CommandDescription
lspciSee general information about host bridge, VGA controller, ethernet controller, USB controller, SATA controller, etc.
dmidecodeSee some information about BIOS, motherboard, chassis, etc.
cat /proc/cpuinfoRetrieve processor type, socket, speed, configured flags, etc.
x86info or x86info -aSee information about the CPU
cat /proc/meminfoSee detailed information about system RAM
lshwList all hardware components and see their configuration details
lshw -C memory -shortDetect number of RAM slots used, speed, and size
hwinfoList details for all hardware, including their device files and configuration options
biosdecodeGet some general information about your system’s BIOS
dmidecode -s bios-vendorRetrieve the name of your BIOS vendor with this simple command
lsusbGet a list of USB devices plugged into your system
ls -la /dev/disk/by-id/usb-*Retrieve a list of USB device files
hdparm -I /dev/sdxGet information about your hard drive’s make, model, serial number, firmware version, and configuration
hdparm -tT /dev/sdxShow the speed of an installed hard drive – including cached reads and buffered disk reads
wodim --devicesLocate CD or DVD device file

Linux Full Course

Related Article’s

The 7 Best Screen Recorders For Linux In 2022

How to Install Brave Browser on Kali Linux

How To Check Kali Linux Version

Advance Linux terminal commands for The Power users

One thought on “Linux Commands Everything you need to know

  1. Needed to compose you a tiny note to finally thank you very much yet again for your personal splendid methods you have discussed above. It isstrangely open-handed with people like you to provide publicly all that a number of people would have marketed as an electronic book to generate some bucks for their own end, primarily now that you could possibly have tried it if you ever wanted. These inspiring ideas likewise acted like a fantastic way to know that the rest have the same dreams really like my personal own to see a whole lot more concerning this problem. I’m sure there are thousands of more enjoyable times in the future for many who check out your blog.black celebrity news

Leave a Reply