linux practical
linux practical
1. pwd — When you first open the terminal, you are in the home directory of your user. To know which
directory you are in, you can use the “pwd” command. It gives us the absolute path, which means the
path that starts from the root. The root is the base of the Linux file system. It is denoted by a forward
slash( / ). The user directory is usually something like "/home/username"
2 cd — Use the "cd" command to go to a directory. For example, if you are in the home folder, and you
want to go to the downloads folder, then you can type in “cd Downloads”. Remember, this command
is case sensitive, and you have to type in the name of the folder exactly as it is. But there is a problem
with these commands. Imagine you have a folder named “Raspberry Pi”. In this case, when you type
in “cd Raspberry Pi”, the shell will take the second argument of the command as a different one, so
you will get an error saying that the directory does not exist. Here, you can use a backward slash. That
is, you can use “cd Raspberry\ Pi” in this case. Spaces are denoted like this: If you just
type “cd” and press enter, it takes you to the home directory. To go back from a folder to the folder
before that, you can type “cd ..” . The two dots represent back.
3 ls — Use the "ls" command to know what files are in the directory you are in. You can see all the
hidden files by using the command “ls -a”.
4 More As 'cat' command displays the file content. Same way 'more' command also displays the
content of a file. Only difference is that, in case of larger files, 'cat' command output will scroll off your
screen while 'more' command displays output one screenful at a time.
Syntax:
Example:
1. more /var/log/udev
The 'less' command is same as 'more' command but include some more features.
It automatically adjust with the width and height of the teminal window, while 'more' command cuts the
content as the width of the terminal window get shorter.
Syntax:
Example:
1. less /var/log/udev
6 echo — The "echo" command helps us move some data, usually text into a file. For example, if you
want to create a new text file or add to an already made text file, you just need to type in, “echo
hello, my name is alok >> new.txt”. You do not need to separate the spaces by using the backward
slash here, because we put in two triangular brackets when we finish what we need to write.
clear Command
Linux clear command is used to clear the terminal screen.
Syntax:
1. clear
7 kill Command
kill is a shell builtin in most Bourne-derived shells such as Bash and Zsh. The command behavior is
slightly different between the shells and the standalone /bin/kill executable.
Use the type command to display all locations on your system containing kill:
8 ps
The ps command lists current running processes alongside their PIDs and other attributes. In this guide,
we are going to focus on ps command usage.
It retrieves information about the processes from virtual files which are located in the /proc file system
9 man
This command is used to move some data into a file. For example, if you want to add the text, “Hello,
my name is John” into a file called name.txt, you would type echo Hello, my name is John >> name.txt
10 cal
If a user wants a quick view of calendar in Linux terminal, cal is the command for you. By
default, cal command shows current month calendar as output.
cal command is a calendar command in Linux which is used to see the calendar of a specific month or
a whole year.
Syntax:
11 date
date command is used to display the system date and time. date command is also used to set date
and time of the system. By default the date command displays the date in the time zone on which
unix/linux operating system is configured.You must be the super-user (root) to change the date and
time.
Syntax:
date [OPTION]...
12 who
Description : The who command is used to get information about currently logged in user on to
system.
13 who am I
whoami command is used both in Unix Operating System and as well as in Windows Operating
System.
It displays the username of the current user when this command is invoked.
14 WC
wc stands for word count. As the name implies, it is mainly used for counting purpose.
It is used to find out number of lines, word count, byte and characters count in the files
specified in the file arguments.
First column shows number of lines present in a file specified, second column shows number of
words present in the file, third column shows number of characters present in file and fourth
column itself is the file name which are given as argument.
Syntax:
wc [OPTION]... [FILE]...
15 mkdir
mkdir command in Linux allows the user to create directories (also referred to as folders in some
operating systems ). This command can create multiple directories at once as well as set the
permissions for the directories. It is important to note that the user executing this command must have
enough permissions to create a directory in the parent directory, or he/she may recieve a ‘permission
denied’ error.
Syntax: