Linux is a free, open-source, Unix-like operating system's kernel. It was created by Linux Torvalds in 1991. The kernel sits between applications and hardware and makes the connections between all of your software and the physical resources that do multiple processes. I personally prefer 'Arch Linux' but there are several Linux Distributions, commonly called 'distros'.
- Arch Linux
Linux Emulator: A terminal emulator is a program that helps us to use the Linux command-line in a graphical environment. Linux command line is often referred to as shell, terminal, console, prompt and so on.
Here are some commonly used terminal emulators by the operating systems.
- Windows: PuTTY
- Linux: Gnome Terminal, KDE Konsole, XTerm, Terminator, Guake
- Mac OS: Terminal (Default), iTerm 2
lswill list all the contents of the current directory.
ls -awill enlist the whole list of the current directory including the hidden files.
$ ls -a
ls -Rlists all the files of current and the subdirectories also.
$ ls -R
mkdir <folder_name>is used to create a new directory.
$ mkdir new_folder
cdis used to change the current working directory.
$ cd <directory_name>
cd ..is used to move to the parent directory of the current directory.
.means current and
..means the previous directory.
$ cd ..
pwdstands for print working directory. the command prints the complete path of the current working directory.
cat > file_name.extensionwill create a new file and it allows us to write some texts into a file.
$ cat > file.txt add some text here and exit by pressing ctrl+shift+c
catis also used to print the content of a file onto the standard output stream.
$ cat <file_name>
- The following command will merge all the contents of both
$ cat file1.txt file2.txt > file3.txt
echois used to display lines of text/string that is passed as an argument.
echoalso overrides new text/string in a file.
manis used to display the user manual of any command that we can run on the terminal.
$ man echo
cpcommand is used to create a copy of the file.
$ cp file1.txt newfile.txt
mvis used to move files
$ mv file.txt <path>
rmis used to remove files or directories
$ rm file.txt
rm -rremoves directories and their contents recursively.
rm -rfremoves directories and their contents forcefully.
rm -dremoves empty directories only.
sudostands for SuperUser DO and is used to access restricted files and operations. sudo was developed to temporarily grant a user administrative rights without login as a root user.
$ sudo [command]
dfis a standard Unix command used to display the amount of available disk space of the file systems.
Using ' -h ' parameter with
df -hwill show the file system disk space stats in “human-readable” format.
headprints the first 10 lines of the specified files.
$ head file.txt
- By default,
tailprints the last 10 lines of the specified files.
$ tail file.txt
grepsearches a file for a particular pattern/ string and displays all lines that contain that pattern.
Options for grep
$ grep [options] [pattern/string] [filename]
-c : Prints only a count of the lines that match a pattern.
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, the case for matching.
-l : Displays list of filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not match the pattern.
-w : Match whole word.
-o : Print only the matched parts of a matching line.
historyis used to view the previously executed command in the terminal.
history | grep '<keyword>'will show all the previously executed commands with the specified keyword.
wgetwill download the resource specified in the [url] to the current directory.
bash $ wget [URL]If you want download files in different name, that add
wget -O [file_name] [URL].
topcommand will show all the current Linux processes.
If you know any process Id and want to stop that process, you can kill it by using the command.
$ kill [PID]
unameprints the name of the kernel.
More commands using
zipis a command that helps you to create Zip archives.
$ zip [archive_name] [file_name]
unziphelps you to unzip archives.
$ unzip files.zip
nslookup(Name Server Lookup) is a useful command for getting information from the DNS server.
ps auxcommand is a tool to monitor processes running on your Linux system.
$ ps aux
ping [URL](Packet Internet Groper) command is used to check the network connectivity between host and server.
$ ping google.com