[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
Command |
Uses |
uname |
Displays linux system information |
cat /etc/redhat_release |
Displays which version of redhat installed |
uptime |
Display how long the system has been running |
hostname |
Display system host name |
last reboot |
Display system reboot history |
date |
Display the current date and time |
cal |
Display the calendar of the current month |
w |
Displays who is logged on |
whoami |
Displays current user id |
finger user |
Displays information about user |
reboot |
Reboots the system |
shutdown |
Shuts down the system |
Hardware Linux Commands
Command |
Uses |
dmesg |
Displays all the messages from Kernel ring buffer |
cat /proc/cpuinfo |
Displays information about processes and CPUs of the system |
cat /proc/meminfo |
Displays details on hardware memory |
cat /proc/interrupts |
Lists the number of interrupts per CPU per I/O device |
lshw |
Displays information on hardware configuration of the system |
lsblk |
Displays block device related information of the machine |
free -m |
Display used and free memory |
dmidecode |
Displays hardware info from the BIOS |
hdparm -i /dev/sda |
Displays info about disk sda |
hdparm -tT /dev/sda |
Performs a read speed test on disk sda |
badblocks -s /dev/sda |
Tests for unreadable blocks on disk sda |
lspci -tv |
Display information on PCI buses devices |
File Linux Commands
Command |
Uses |
ls -al |
Displays all information about files/directories. |
pwd |
Shows current directory path |
mkdir directory-name |
Creates a directory |
cp file1 file2 |
Copies linux files, here file1 to file2 |
cp -r dir1 dir2 |
Copies dir1 to dir2, creates dir2 if it doesn’t exist |
mv file1 file2 |
Moves files from one place to another/renames file1 to file2 |
rm file-name |
Deletes file |
rm -r directory-name |
Deletes directory recursively |
rm -f file-name |
Forcefully removes file |
rm -rf directory-name |
Forcefully removes directory recursively |
ln -s /path/to/file-name link-name |
Creates a symbolic link to file-name |
tail -f file |
Outputs the contents of file as it grows starting with the last 10 lines |
gpg -c file |
Encrypts file |
gpg file.gpg |
Decrypts file |
cksum file |
View the checksum of the file |
diff file1 file2 |
View the differences between contents of file1 and file2 |
ln -s link file |
Create a soft link named link to the file |
sort |
Sorts files in alphabetical order |
touch file |
Creates empty file |
cat file |
Prints the file content in terminal |
more file |
Display the contents of file |
head file |
Display the first 10 lines of file |
tail file |
Outputs the last 10 lines of file |
uniq |
Compares adjacent lines in a file and removes/reports any duplicate lines |
wc |
Counts number of words/lines |
dir |
Lists the content of the directory |
tee |
Command for chaining and redirection |
tr |
Command for translating characters |
File Permission & Network Linux Commands
Command |
Uses |
chmod octal file-name |
Changes the permissions of file to octal |
chmod 777 /data/test.c |
Sets rwx permission for owner , group and others |
chmod 755 /data/test.c |
Sets rwx permission for owner and rx for group and others |
chown owner-user file |
Changes owner of the file |
chown owner-user:owner-group file-name |
Changes owner and group owner of the file |
chown owner-user:owner-group directory |
Changes owner and group owner of the directory |
chgrp group1 file |
Changes the group ownership of the file to group1 |
ifconfig -a |
Displays all network interface and set ip address |
ifconfig eth0 |
Displays eth0 ethernet port ip address and details |
ip addr show |
Display all network interfaces and ip addresses |
ip address add 192.168.0.1 dev eth0 |
78. ip address add 192.168.0.1 dev eth0 : Sets ip address of eth0 device |
ethtool eth0 |
Linux tool to show ethernet status |
mii-tool eth0 |
Linux tool to show eth0 status |
ping host |
Sends echo requests to the host to test ipv4 connection |
whois domain |
Gets who is information for domain |
dig domain |
Gets DNS nameserver information for domain |
dig -x hos |
Reverse lookup host |
host google.com |
Lookup DNS ip address for the name |
hostname -i |
Lookup local ip address |
wget file |
Downloads file |
netstat -tupl |
Lists all active listening ports |
nslookup |
Resolves domain names to IP addresses |
Package Installation & Search Linux Commands
Command |
Uses |
rpm -i pkgname.rpm |
Installs rpm based package |
rpm -e pkgname |
Removes package |
make |
Install from source file |
grep pattern files |
Searches for pattern in files |
grep -r pattern dir |
Searches recursively for pattern in dir |
locate file |
Finds all instances of file |
find /home/tom -name ‘index*’ |
Finds file names that start with “index” inside /home/tom directory |
find /home -size +10000k |
Finds files larger than 10000k in /home |
Login, File Transfer & Disk Usage Commands
Command |
Uses |
ssh [email protected] |
Securely connect to a host as user |
ssh -p port $ [email protected] |
Connects to host using specific port |
telnet host |
Connects to the system using telnet port |
scp file.txt server2:/tmp |
Secure copy file.txt to remote host /tmp folder |
scp [email protected]:/www/*.html /www/tmp |
Copies *.html files from remote host to current host /www/tmp folder |
scp -r [email protected]:/www /www/tmp |
Copies 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]:/backup |
Synchronize files/directories between the local and remote system with compression enabled |
df -h |
Displays free space on mounted filesystems |
df -i |
Displays free inodes on mounted filesystems |
fdisk -l |
Displays disks partitions sizes and types |
du -ah |
Displays disk usage in human readable form |
du -sh |
Displays total disk usage on the current directory |
findmnt |
Displays target mount point for all filesystems |
mount device-path mount-point |
Mounts a device to the device-path |
[ad_2]