PRACTICAL 2
Name - kushaggra chaudhary
Enroll - A2305218568
Section - 7CSE 9X
AIM - TO study linux general purpose commands
1. pwd command
Use the pwd command to nd out the path of the current working directory (folder) you’re in. The
command will return an absolute (full) path, which is basically a path of all the directories that
starts with a forward slash (/). An example of an absolute path is /home/username.
2. cd command
To navigate through the Linux les and directories, use the cd command. Another scenario is if
you want to switch to a completely new directory, for example,/home/username/Movies. In this
case, you have to type cd followed by the directory’s absolute path: cd /home/username/Movies.
There are some shortcuts to help you navigate quickly:
• cd .. (with two dots) to move one directory up
• cd to go straight to the home folder
• cd- (with a hyphen) to move to your previous directory
3. ls command
The ls command is used to view the contents of a directory.
There are variations you can use with the ls command:
• ls -R will list all the les in the sub-directories as well
• ls -a will show the hidden les
• ls -al will list the les and directories with detailed information like the permissions, size,
owner, etc.
4. cat command
cat (short for concatenate) is one of the most frequently used commands in Linux. It is used to list
the contents of a le on the standard output (sdout). For instance: cat le.txt.
Here are other ways to use the cat command:
• cat > lename creates a new le
• cat lename1 lename2> lename3 joins two les (1 and 2) and stores the output of them in a
new le (3)
• to convert a le to upper or lower case use, cat lename | tr a-z A-Z >output.txt
5. cp command
Use the cp command to copy les from the current directory to a di erent directory. For instance,
the command cp scenery.jpg /home/username/Pictures would create a copy of scenery.jpg (from
your current directory) into the Pictures directory.
6. mv command
The primary use of the mv command is to move les, although it can also be used to rename les.
The arguments in mv are similar to the cp command. You need to type mv, the le’s name, and
the destination’s directory. For example: mv le.txt /home/username/Documents.
To rename les, the Linux command is mv oldname.ext newname.ext
7. mkdir command
Use mkdir command to make a new directory — if you type mkdir Music it will create a directory
called Music.
There are extra mkdir commands as well:
• To generate a new directory inside another directory, use this Linux basic command mkdir
Music/New le
• use the p (parents) option to create a directory in between two existing directories. For
example, mkdir -p Music/2020/New le will create the new “2020” le.
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
ff
fi
fi
fi
8. rmdir command
If you need to delete a directory, use the rmdir command. However, rmdir only allows you to
delete empty directories.
9. rm command
The rm command is used to delete directories and the contents within them. If you only want to
delete the directory — as an alternative to rmdir — use rm -r.
Note: Be very careful with this command and double-check which directory you are in. This will
delete everything and there is no undo