Site icon DarkWorld Network

Linux Commands

CommandsDescription
ls
To list down all the contents of directory
cd
To change the directory
cd /bin/
Change current directory to bin directory
cd ~
The tilde (~) sign signifies the user’s home dir – change dir
to home directory
cd ..
It changes directory one level up
mkdir
To create a directory
pwd
It display current directory path
cat <filename>
Command to print all the contents of provided filename on the screen
cp
It copies the file or directory
cp /home/dw /home/linux
It copies the /home/dw/ directory to /home/linux/ directory
mv
mv move command is used to move files and directories
mv /home/dw/info.txt /newDirectoryName/
It moves the file info.txt to the /newDirectoryName/ directory.
You can also use this command to move the entire directory to another Directory
rm
rm command is used to remove files and directories.
rm info.txt
This command will remove the file info.txt
find
find command perform search of file
find / -name “linux*”
The find command is a powerful tool that you can use when searching using the command line. The command here will search for any file or directory with a name that starts with linux
uname -a
This command displays information about the machine, the processor architecture, and the operating system details.
lscpuThis command returns more information about the system such as the number of CPUs and the CPU speed
cat /proc/cpuinfoThis is a file that contains more information than the one displayed using the lscpu command
df -hThis command displays the disk space usage in all of the mounted devices. The -h option presents the results in a human readable output, using G for gigabytes or M for megabytes sizes
du ~/DownloadsThis command displays all the files inside the specified directory and their corresponding file sizes. You can also specify a filename
du ~/Downloads -shThe –s option provides the total file size of the specified directory and -h makes it human readable form
KeysDescriptionExample
infoShows online information about a command$ info uname
manShows details (manual) of a command$ man uname
whatisShows a short description of a specific keyword$ whatis uname
typeShows the location of a command file$ type uname
aliasAssign a command alias – especially useful for long commands$ alias t=type
$ t uname
$ alias
unaliasRemove command alias$ unalias t
pwdDisplays the current directory$ pwd
lnCreate links to files and directories$ ln -s [file] [soft-link-to-file]
$ ln -s info.txt newinfo.txt
touchTo trigger a file stamp update for a file$ touch info.txt
findSearch for a file based on the name$ find [dir-path] -name [filename]
$ find . -name info.jpeg
whereisSearch for executable files$ whereis uname
whichSearch for files in the directories part of the PATH variable$ which uname
ddCopy lines of data$ dd conv=ucase
Type Hello world ctrl+d
$ echo “hello world > info.txt
$ dd if=info.txt of=newinfo.txt
conv=ucase
$ cat newinfo.txt
diffDisplay the results of comparing two files$ echo “hello world > info.txt
$ echo “hello world > info1.txt
$ diff info.txt info1.txt -s
$ echo “hello world123 > newinfo.txt
$ diff info.txt newinfo.txt -s
moreShow a text file one page at a time – display can only go forward$ ls -R > info.txt
$ more info.txt
$ ls -R | more
lessShow a text file one page at a time – display can only go forward and backwards$ less info.txt
$ ls -R | less
wcDisplay the count of the number of characters, words, and lines in a file$ wc info.txt
cutGet sections of text in a file$ cut -b 1 info.txt
$ cut -b 1-3 info.txt
$ cut -b 1,3 info.txt
grepDisplay results of finding expressions in a file$ cat info.txt | grep Desktop
$ cat info.txt | grep -i desktop
$ grep -i “desktop” info.txt
sedPerform editing commands, then copy to a standard outputFirst occurance in every line will be
changed
$ dw’s/Desktop/Dashboard/’ info.txt
2nd occurance in every line will be
changed
$ dw ‘s/Desktop/Dashboard/2’ info.txt
All occurances will be changed
$ dw ‘s/Desktop/Dashboard/g’ info.txt
splitSpecify a size to break a file into$ split info.txt
$ ls
$ rm x* -l100 is 100 lines per file
$ split -l100 info.txt
$ ls
sortArrange the lines in a file$ sort info.txt
uniqKeep unique lines in a file and delete duplicates$ echo “Hey Hi Hello Commands Linux Irc” > info.txt
$ cat info.txt
$ uniq info.txt
$ uniq info.txt -c
$ uniq info.txt -d
tarArchive files with one or more directoriesArchive the file
$ tar -cf archive.tar file1 file2
Extract the files
$ tar -xf archive.tar
calShow the calendar for the specified month or year$ cal
$ cal -3
$ cal -m 5
$ cal -y 2020
dateShow/Set the current date and time$ date Sets the system date and time to given date
$ date -s “11/20/2003 12:48:00”
bgRun a program or a process in the background$ bg %[PID]
freeCheck for the free memory$free
killStop a process$ kill <PSID>
niceRun a program with a low priority, niceness values range from -20 to 19, with the former being most favorable, while latter being least$ nice -10 ls -R
$ nice –10 ls -R
psShow current running processes$ps
topShow list of CPU and memory
utilization of processes
$top
rebootRestart the system$reboot
shutdownTurn off system$shutdown
Exit mobile version