Startertutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.

Categories: Unix Programming. No Comments on Directories and File Names in Unix
0
(0)

In this article you will learn about directories and file names in Unix with examples. You will also learn associated commands with directories and file names in Unix like ls, pwd, mkdir, cd and du.

 

All the files in the system will have unique names. When we try to print the list of files and/or directories in the current directory, it will not display the absolute path of the file/directory. It will only print the file/directory names as shown below:

 

Directories and File Names in Unix ls command

 

This is because every process like ls will have current working directory, and all filenames are implicitly assumed to start with the name of that directory. We can print the current working directory by using the pwd command as shown below:

 


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


Directories and File Names in Unix pwd command

 

The current directory is an attribute of a process, not a program. The notion of current directory is purely for organizational purposes. We can create a directory in the current working directory using the mkdir command as shown below. After creating your directory you can move into that directory using the cd command as shown below:

 

Directories and File Names in Unix mkdir cd commands

 

The du (disc usage) command can be used to find out how much space is consumed by the files in the current directory and subdirectories as shown below:

 

Directories and File Names in Unix du command

 

The number at the starting of each line represents the number of disk blocks occupied by each file/directory. The character ‘.’ (dot) represents the current directory and ‘..’ represents parent directory. The directory / is called the root of the file system. Every file in the system is in the root directory or one of its subdirectories, and the root is its own parent directory.

 

I hope you enjoyed this article. You will learn about Unix directory hierarchy and inodes in the coming articles.

 

For additional information you can visit the following links:

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Suryateja Pericherla

Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.

He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.

He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.

Leave a Reply

Your email address will not be published. Required fields are marked *