Linux Directory and File Operations
Most basic linux usage start with linux file and directory operations. We will look these operations to cover basics.
List Directories and Files
Start of the navigation in file system starts with listing the directories and files
List Hidden Files and Directories
All operating systems have hidden files to hide it from used. It is not security related feature. It it related about operation and reliability. Showing configuration files in home directory have no benefits. So by default hiding them is better.
$ ls -a
List Files and Folders Recursively
We can all child files and directories by providing recursive option
$ ls -R
We can go to the root
$ cd /
We can go to the home directory
$ cd ~
We can go to upper directory
We can go to the log directory
$ cd /var/log
Show Working Directory
We can work different systems and directories in day to day operation. We may not remember current directory of the shell. We can get current working directory with pwd command.
Delete File and Directory
We may need to delete a file or folder. rm and rmdir are commands used to delete file and directories.
$ rmdir output/
rmdir: failed to remove 'output/': Directory not empty
I can not deleted the directory because there are files or directories in it. We can force for deletion
$ rm -Rf output
- -Rf option will make deletion recursive and forcibly.
Move Files and Directories
We can use mv command to move files and directories
$ mv mycommand yourcommand
$ mv output/ output2