Linux

Most Linux Commands Used Frequently With Examples

[ad_1]

In this article we give you the most as often as possible used Linux Commands. Coming from the solace of a PC or Mac work area, the Linux Command Line looks not at all like what you regularly utilize.

For somebody to work in the Terminal they have to acquaint themselves with Linux commands. The Linux Command line is very helpful, fundamental to utilizing your Linux or VM and if done right, it furnishes you with more understanding and handy use than the Windows or Mac work area ever could.

System Linux Commands

CommandUses
unameDisplays linux system information
cat /etc/redhat_releaseDisplays which version of redhat installed
uptimeDisplay how long the system has been running
hostnameDisplay system host name
last rebootDisplay system reboot history
dateDisplay the current date and time
calDisplay the calendar of the current month
wDisplays who is logged on
whoamiDisplays current user id
finger userDisplays information about user
rebootReboots the system
shutdownShuts down the system

Hardware Linux Commands

CommandUses
dmesgDisplays all the messages from Kernel ring buffer
cat /proc/cpuinfoDisplays information about processes and CPUs of the system
cat /proc/meminfoDisplays details on hardware memory
cat /proc/interruptsLists the number of interrupts per CPU per I/O device
lshwDisplays information on hardware configuration of the system
lsblkDisplays block device related information of the machine
free -mDisplay used and free memory
dmidecodeDisplays hardware info from the BIOS
hdparm -i /dev/sdaDisplays info about disk sda
hdparm -tT /dev/sdaPerforms a read speed test on disk sda
badblocks -s /dev/sdaTests for unreadable blocks on disk sda
lspci -tvDisplay information on PCI buses devices

File Linux Commands

CommandUses
ls -alDisplays all information about files/directories.
pwdShows current directory path
mkdir directory-nameCreates a directory
cp file1 file2Copies linux files, here file1 to file2
cp -r dir1 dir2Copies dir1 to dir2, creates dir2 if it doesn’t exist
mv file1 file2Moves files from one place to another/renames file1 to file2
rm file-nameDeletes file
rm -r directory-nameDeletes directory recursively
rm -f file-nameForcefully removes file
rm -rf directory-nameForcefully removes directory recursively
ln -s /path/to/file-name link-nameCreates a symbolic link to file-name
tail -f fileOutputs the contents of file as it grows starting with the last 10 lines
gpg -c fileEncrypts file
gpg file.gpgDecrypts file
cksum fileView the checksum of the file
diff file1 file2View the differences between contents of file1 and file2
ln -s link fileCreate a soft link named link to the file
sortSorts files in alphabetical order
touch fileCreates empty file
cat filePrints the file content in terminal
more fileDisplay the contents of file
head fileDisplay the first 10 lines of file
tail fileOutputs the last 10 lines of file
uniqCompares adjacent lines in a file and removes/reports any duplicate lines
wcCounts number of words/lines
dirLists the content of the directory
teeCommand for chaining and redirection
trCommand for translating characters

File Permission & Network Linux Commands

CommandUses
chmod octal file-nameChanges the permissions of file to octal
chmod 777 /data/test.cSets rwx permission for owner , group and others
chmod 755 /data/test.cSets rwx permission for owner and rx for group and others
chown owner-user fileChanges owner of the file
chown owner-user:owner-group file-nameChanges owner and group owner of the file
chown owner-user:owner-group directoryChanges owner and group owner of the directory
chgrp group1 fileChanges the group ownership of the file to group1
ifconfig -aDisplays all network interface and set ip address
ifconfig eth0Displays eth0 ethernet port ip address and details
ip addr showDisplay all network interfaces and ip addresses
ip address add 192.168.0.1 dev eth078. ip address add 192.168.0.1 dev eth0 : Sets ip address of eth0 device
ethtool eth0Linux tool to show ethernet status
mii-tool eth0Linux tool to show eth0 status
ping hostSends echo requests to the host to test ipv4 connection
whois domainGets who is information for domain
dig domainGets DNS nameserver information for domain
dig -x hosReverse lookup host
host google.comLookup DNS ip address for the name
hostname -iLookup local ip address
wget fileDownloads file
netstat -tuplLists all active listening ports
nslookupResolves domain names to IP addresses

Package Installation & Search Linux Commands

CommandUses
rpm -i pkgname.rpmInstalls rpm based package
rpm -e pkgnameRemoves package
makeInstall from source file
grep pattern filesSearches for pattern in files
grep -r pattern dirSearches recursively for pattern in dir
locate fileFinds all instances of file
find /home/tom -name ‘index*’Finds file names that start with “index” inside /home/tom directory
find /home -size +10000kFinds files larger than 10000k in /home

Login, File Transfer & Disk Usage Commands

CommandUses
ssh [email protected]Securely connect to a host as user
ssh -p port $ [email protected]Connects to host using specific port
telnet hostConnects to the system using telnet port
scp file.txt server2:/tmpSecure copy file.txt to remote host /tmp folder
scp [email protected]:/www/*.html /www/tmpCopies *.html files from remote host to current host /www/tmp folder
scp -r [email protected]:/www /www/tmpCopies all files and folders recursively from remote server to the current system /www/tmp folder
rsync -a /home/apps /backup/Synchronizes source to destination
rsync -avz /home/apps $ [email protected]:/backupSynchronize files/directories between the local and remote system with compression enabled
df -hDisplays free space on mounted filesystems
df -iDisplays free inodes on mounted filesystems
fdisk -lDisplays disks partitions sizes and types
du -ahDisplays disk usage in human readable form
du -shDisplays total disk usage on the current directory
findmntDisplays target mount point for all filesystems
mount device-path mount-pointMounts a device to the device-path
[ad_2]

Show More

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close