DEV Community

Tina Popli
Tina Popli

Posted on

UNIX - DIRECTORIES (PART 2)

Let us now see how to create new directories.
if we have many files all together, it is always preferable to organize them based on their similarities into same directory.

3) MKDIR

SYNTAX:

mkdir (pathname)

pathname is the path of the directory to be created.

Example : To create a new directory under the HOME Directory.

$ mkdir employees

$ cd employees (from home directory change to employees)
$ pwd (verifying it's path)
/home/employees

  • When we create a new directory, the system builds a new inode (information node ) for the directory.

4) LS

This command can be used to display the names of files and directories.

$ pwd
/home/employees

$ls
employee1 employee2

SYNTAX:

ls [options]

where options can be

i) ls -m Lists directory contents separated by a comma.
ii) ls -Q Displays directory contents enclosed by quotation marks.
iii) ls -l Displays files in a long-list format.
iv) ls -lh Display file size in a human-readable format.
v) ls -g Omits group ownership column.
vi) ls -F Adds a forward slash to directories.
vii) ls -i Display inode number of files and directories.
viii) ls -a Display all files including hidden files.
ix) ls *. Filters files according to the file extension.
x) ls -la Displays all files and directories in long list format.
xi) ls -R Display files and directories recursively.
xii) ls -r Sort Files in reverse.
xiii) ls -X Sort files alphabetically by file extension.
xiv) ls -tl Display files according to file creation date and time.
xv) ls -n List UIDs and GIDs.

Top comments (0)