Linux Command
Linux Command
$ cal
pwd
•This command is used to find out the path of
the current working directory (folder) that
you’re in.
$ pwd
Example: /home/username
cd
•To navigate through the Linux files and
directories, use the cd command.
$ cd
$ cat> filename
$ touch filename
$ wc filename
2 19 103 filename
$
head command
• The head command is used to view the first ten
number of lines of any text file.
• By default, it will show the first ten lines, but you
can change this number to your liking.
• For example, if you only want to show the first
five lines, type
head -n 5 filename.ext.
tail command
• The tail command will display the last ten lines of
a text file.
For example:
tail -n filename.ext.
diff command
• The diff command compares the contents of two
files line by line
man command_name
history Command
• History command shows all the commands
that you have used in the past for the current
terminal session.
•This can help you refer to the old commands
you have entered and re-used them in your
operations again.
•history
clear Command
• This command clears all the clutter on the
terminal and gives you a clean window to work
on, just like when you launch the terminal.
•clear
echo Command
•The echo command prints (echoes) a string of
text to the terminal window.
•exit
grep Command
•The grep command can also search the
contents of files. Here we’re searching for the
word “train” in all text files in the current
directory.
•shutdown
•shutdown now
DIRECTORIES
Home Directory
•The directory in which you find yourself when
you first login is called your home directory.
•You will be doing much of your work in your
home directory and subdirectories that you'll be
creating to organize your files.
•You can go in your home directory anytime
using the following command:
$ cd ~
Here ~ indicates home directory.
Creating Directories
•Directories are created by the following
command:
$mkdir dirname
Removing Directories
•Directories can be deleted using the rmdir
command as follows:
$rmdir dirname
Note: To remove a directory make sure it is
empty which means there should not be any file
or sub-directory inside this directory.
ln target.txt link.txt
ls
target.txt link.txt
cat link.txt
target file
Editing link.txt has the effect of changing the
underlying data on disk.
Vi link.txt
target file
link edit
cat target.txt
target file
link edit
How to create a symbolic link
To create a symbolic link pass the -s option
to the ln command followed by the target file
and the name of link.
ln -s ~/code/notes/notes ~/bin/notes
What is an INODE
User ID of file
Group ID of file
Device ID
File size
Date of creation
Permission
Owner of the file
File protection flag
Link counter to determine number of hard links
Inode Table