Linux Commands Line For You – Daily Use

Linux Commands Line For You – Daily Use

The shell (or terminal) in Linux is a power user’s and a developer’s lifeline. Using commands on the terminal is a far more effective way to carry out actions that may be carried out on the GUI (by clicking on various buttons). One may not be able to recall every command, but with consistent use, one may quickly recall the ones that are most useful.

File Commands

CommandShort Description
lslist files in directory
ls -alist all files, including hidden
pwdshow the directory currently working in
mkdir [directory]create a new directory
rm [file_name]remove a file
rm -r [directory_name]remove a directory recursively
rm -rf [directory_name]remove a directory recursively without requiring confirmation
cp [file_name1] [file_name2]copy the contents of the first file to the second file
cp -r [directory_name1] [directory_name2]recursively copy the contents of the first directory into the second directory
mv [file_name1] [file_name2]rename file_name1 to file_name2
ln -s /path/to/[file_name] [link_name]create a symbolic link to a file
touch [file_name]create a new file
more [file_name]show the contents of a file
head [file_name]show the first 10 lines of a file
tail [file_name]show the last 10 lines of a file
gpg -c [file_name]encrypt a file
gpg [file_name.gpg]decrypt a file
wcprint the number of words, lines, and bytes in a file
File Commands

Disk Usage

CommandShort Description
df -hshow free and used space on mounted systems
df -ishow free inodes on mounted filesystems
fdisk -lshow disk partitions, sizes, and types
du -ahshow disk usage for all files and directory
du -shshow disk usage of current directory
findmntshow target mount point for all filesystems
mount [device_path] [mount_point]Untitled
mount a device
Disk Usage

File Permission

CommandShort Description
chmod 777 [file_name]give read, write, and execute permission to everyone
chmod 755 [file_name]give full permission to owner, and read and execute permission to group and others
chmod 766 [file_name]give full permission to owner, and read and write permission to group and others
chown [user] [file_name]change the file ownership
chown [user]: [group] [file_name]change the owner and group ownership of a file
File Permission

Directory Navigation

CommandShort Description
cd ..move up one level in the directory tree structure
cdchange directory to $HOME
cd /chosen/directorychange to specified directory
Directory Navigation

Keyboard Shortcuts

CommandShort Description
Ctrl + Ckill current process running in the terminal
Ctrl + Zstop current process (can be resumed in the foreground with fg or in the background with bg)
Ctrl + Wcut one word before the cursor and add it to clipboard
Ctrl + Ucut part of the line before the cursor and add it to clipboard
Ctrl + Kcut part of the line after the cursor and add it to clipboard
Ctrl + Ypaste from clipboard
Ctrl + Rrecall last command that matches the provided characters
Ctrl + Orun the previously recalled command
Ctrl + Gexit command history without running a command
!!repeat the last command
exitlog out of current session
Keyboard shortcuts

Hardware Information

CommandShort Description
dmesgshow bootup messages
cat /proc/cpuinfoshow CPU information
free -hshow free and used memory (-m flag indicates memory in MB)
lshwlist information about hardware configuration
lsblklist information about block devices
lspci -tvshow PCI devices in a tree-like diagram
lsusb -tvshow USB devices in a tree-like diagram
dmidecodeshow hardware information from the BIOS
hdparm -i /dev/[disk]show information about disk data
hdparm -tT /dev/[disk]conduct a read speed test on disk
badblocks -s /dev/[disk]test for unreadable blocks on disk
Hardware Information

System Information

CommandShort Description
uname -rshow system information
uname -ashow kernel release information
uptimeshow how long the system has been running, including load average
hostnameshow system hostname
hostname -ishow the IP address of the system
last rebootshow system reboot history
dateshow current time and date
timedatectlquery and change the system clock
calshow current calender month and day
wshow logged in users in the system
whoamishow user you are using
finger [username]show information about a user
System Information

Searching

CommandShort Description
grep [pattern] [file_name]search for a specific pattern in a file
grep -r [pattern] [directory_name]search recursively for a specific pattern in a directory
locate [name]find all files and directories by a specific name
find [/folder/location] -name [a]list names that begin with [a] in [/folder/location]
find [/folder/location] -size [+100M]list files larger than 100M in a particular folder
Searching

Moving around in the Command Line

Keyboard Shortcut keysAction
Ctrl + AMove to the beginning of the line
Ctrl + EMove to the end of the line Move to the
Ctrl + BMove to the previous word
Ctrl + FMove to the next word
Ctrl + UCuts to the beginning of the line
Ctrl + KCuts to the end of the line
Ctrl + WCuts the previous word
Ctrl + PBrowse previously entered commands
Ctrl + RReverse search for previously entered commands
Moving around in the command line

Techinfo Avatar

Leave a Reply

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