Linux Directory and File Operations – POFTUT

Linux Directory and File Operations

Most basic Linux usage starts with Linux file and directory operations. We will look at these operations to cover basics. In this tutorial, we will learn commands like ls , cd , mv .

List Directories and Files

Start of the navigation in the file system starts with listing the directories and files. We will use the ls command which will list current working directory files and folders.

List Directories and Files

List Directories and Files

List Hidden Files and Directories

All operating systems have hidden files to hide them from use. It is not a security-related feature. It related to operation and reliability. Showing configuration files in the home directory have no benefits. So by default hiding them is better.

List Hidden Files and Directories

List Hidden Files and Directories

We can see that files and folders like .cpan, .npm, .config etc. are listed with the help of -a option.

List Files and Folders Recursively

We can all child files and directories by providing the recursive option. We will provide the -R option which will list files and folders recursively.

List Files and Folders Recursively

List Files and Folders Recursively

Change Directory

cd or change directory command can be used to change to the different directories. We can provide just the relative or complete path to the cd command.

Change Directory

Change Directory

Go User Home Directory

We can go to the home directory by using ~ tilde which means current user home.

Go Upper/Parent Directory

We can go to the upper directory with double point .. which means parent directory

LEARN MORE  How to Deal With Dashed File Names Like Open, Remove?

Go Given Path

We can go to the log directory

Go Given Path

Go Given Path

Show Working Directory

We can work different systems and directories in day to day operation. We may not remember the current directory of the shell. We can get the current working directory with pwd command.

Show Working Directory

Show Working Directory

Delete File and Directory

We may need to delete a file or folder. rm and rmdir are commands used to delete file and directories.

I can not delete the directory because there are files or directories in it. We can force for deletion

  • -Rf option will make deletion recursive and forcibly.

Move Files and Directories

We can use mv command to move files and directories

Leave a Reply

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