Wednesday, July 26, 2017

Linux Basics - Directory and File Commands

Before moving to commands related to files and directory manipulation commands, it is important to understand the structure of the file system in Linux.

Unlike in Windows file system where you can find separate partitions like C:/, Linux has a root directory denoted by /. root directory is the beginning of the Linux file system. Root directory contains sub directories and files.


You can find the your current working directory using the command pwd

To move around the directory structure using the cd command
cd .. move up by one directory.
cd - - go back to the previous directory
cd [path] - navigate to given path, path can be absolute or relative to the your current working directory. 

to see the content of the current working directory you can use ls command you can use parameters like a,l to customize the output of the ls command. 
a - all files and directories including hidden files
l - long listing format.

mkdir command can be used to make new directories and touch command can be used to create empty files.

to remove directories and files rm command can be used. Remember, to remove directory -r argument should be used along with the rw command.

to copy a file or directory you can use cp command
cp [source] [destination path]

mv command can be used to rename files and directories or to move them, if you do not provide a different path  mv command will rename the given file or directory.

aaaaaannnd that's it for the basic directory and file commands of Linux, to know more about these commands use man command.

No comments:

Post a Comment