Absolute Paths and Pwd

Basically, our computer file structure defined like Directory >folder >Files.

Operating System organize their folders in a hierarchy (a tree) with parents and children, all relative to a base root directory.

What’s mean by root directory?

In a computer file system, and primarily used in the UNIX and Unix-like operating systems, the root directory is the first or top-most directory in a hierarchy. It is like trunk of a tree, as the starting point where all branches originate from. Check below image all folders starting point are root, Root directory mention by "/".

file-system-python But all terminal are start from home directory, Home directory mean a disk folder that contains the user's personal files.in above pic jack is the home directory. So my absolute path will look like "/users/jack". When you open terminal its start with home directory "~".

So next step when we start working in terminal we have to check where actually working in computer.

For example, check below chart just think we are in Test folder, and but we have to confirm the path for that we have to use command call "pwd" the command pwd (print working directory) will tell you the full absolute path of where you're at!.

If you issue pwd command in terminal you’ll get below result

								>	~ pwd
>	/users/jack/test folder



Using CD

In this section we are going see how to navigate from one directory to another. Basically, there is two method for this

  • Navigating Absolutely
  • Navigating Relatively

Navigating Absolutely

The command "CD"? ("change directory"?) followed by the absolute path of the folder will navigate you directly there. For example, refer below chart cd-command-file-system Just say if you’re in Test folder and you wanted to go back to the user directory. For that

Pwd – to check the current path
Users/jack/Testfolder - you’ll get this as result
Cd /users - when you wanted to move to user’s directory
pwd – to verify

Navigating Relatively

cd-file-system Just say if you’re in Test folder and you wanted to go back to the jack directory. For that

Pwd – to check the current path
Users/jack/Testfolder - you’ll get this as result
cd .. - When you wanted to move to user’s directory
pwd – to verify

Using LS

In this section we are going to see the use of command ls. ls is a command to list computer files in Unix and Unix-like operating systems. ls is specified by POSIX and the Single UNIX Specification. When invoked without any arguments, ls lists the files in the current working directory.

Ls – a :

The keyword "ls" will "List" the contents of a directory. You can supply options such as "-a" to list all files (including hidden ones)

Ls- l :

This option will help you to list all the files in directory. In the longer formed it might help you to see access level of the files and directories

Making directories with mkdir

In this section we are going to see how to create a directory. To create a directory, we use command call mkdir, This means make directory, when we wanted to create directory use mkdir command followed by the name of the new directory will create a new child directory inside the current directory.

For example, refer below chart. make-directory-command-line Just say you're inside the Test folder inside that you wanted to create another folder call movie for that mkdir movie, when you use this command you’ll get below result move-directory-cmd In order to check absolute path, if you issue PWD command you'll get below result

/users/jack/Test folder/Movie

Creating Files with touch

In this section, we are going to see how to create a file. To create a file, we use command call "touch" when we wanted to create file use the command touch followed by the filename and file-type extension will create a new file of that type.

What does touch mean :

Touch is a standard UNIX command-line interface program which is used to create a file or update the access date and/or modification date of a file or directory. In its default usage, it is the equivalent of creating or opening a file and saving it without any change to the file contents For example, if you wanted to create text file inside movie directory

touch test.txt   (to create a file)
ls               (to verify the file is create or not)
test.txt         (you’ll get result like this if file create successfully)


Moving and renaming with MV

In this section we are going to see how to move and rename file name. Files can be moved or renamed using the mv (move) Keyword.

What command MV means :

mv (short for move) is a Unix command that moves one or more files or directories from one place to another. If both filenames are on the same file system, this results in a simple file rename; otherwise the file content is copied to the new location and the old file is removed.

For Example:
This is what we currently having file inside test folder. If we wanted to change the file name test.txt to cat.txt rename-file-cmd-python If you want to move file from one directory to an other

mv "test.txt" "cat.txt"  (to rename the test.txt to cat.txt)
ls                       (to verify )
cat.txt                  (Result)

Another way of moving is:

mv /user/jack/test folder/test.txt  /user/jack/test.txt

Deleting Files with RM

In this section, we are going to see how to delete files. Files can be deleted using the rm (remove) keyword.

rm command means :

In computing, rm (short for remove) is a basic command on UNIX and Unix-like operating systems used to remove objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets. ... The command is also available in the EFI shell.

Example: We have to delete the file cat.txt delete-files-python

rm cat.txt   (To remove the file cat.txt)
ls            ( to verify the its removed or not )
test folder   ( result)


Note: we can use this rm command only to remove files.

Deleting Directories

In this section, we are going to see how to delete directories. We can delete directories straight away like we did to files because directories might have lot of files or many directories, but directories can also can be deleted using the "rm" keyword, with the added option "-r" ("recursive". You can also use "-f") ("force") to prevent warnings.

The command rmdir means :

UNIX command that removes a folder, the folder must be empty, and the command must be entered from the previous level or a non-related directory. RMDIR and RD are two forms of the command for Windows and DOS, but only RMDIR works in UNIX.

The command "rm –r" means :

Which removes directories, removing the contents recursively beforehand (so as not to leave files without a directory to reside in) ("recursive")

The command "rm –rf" means :

When you combine the -r and -f flags, it means that recursively and forcibly remove a directory (and its contents) without prompting for confirmation.

The command "man" mean :

A man page in a Linux or other Unix-like operating system is an online description of an interactive shell command, system interface, or system object.

A system user can request the display of a man page simply by entering the man command followed by a space and then the name of the desired command or other entity.

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Recent Addition

new tutorial Selenium Online Training : Our next online training course for Selenium with Java starts from 17th December 2018.

You can attend first 3 classes for free, the total course fee is INR 10,000

The course time would be 8.00 PM(IST) for the first three classes

If you are interested to learn, then you can join the course by sending email to chercher.tech@gmail.com

or Register below

Join My Facebook Group
Join Group