Linux basics



Lets discuss some basics of linux in this post. I don't want to discuss about the history of linux OS. As past is past and we can't go there at this moment there is no point in talking about the past. So let we start from the directory structure of linux OS.

Linux directory structure

/ is the root folder. It contain other folders such as root, home, usr, etc, dev, var, bin, boot, run, sbin, tmp.

/root  : Home directory for the super user. i.e., root
/home: Home directory for regular users where there personal data's are stored.
/usr    : Installed software, shared libraries, include files and static read only program data.
/etc    : All the configuration files are stored here.
/dev   : All the device files are listed here.(All hardware are treated as file in Linux)
/var    : Files that dynamically change (variables). All log files are found in this directory.
/tmp   : Contains temporary files. Files older than ten days are deleted automatically in all Linux systems

Linux basic commands 

touch: Used to create an empty file of any type (actual use isto update timestamp of a file)

syntax: touch <filename.type>

eg: touch newfile.txt
  
This command will create an empty file newfile.txt in the present working directory.
eg: touch /home/newfile.txt
This command will create an empty file newfile.txt in the home directory.

cd: This command is used to change working directory.

syntax: cd <path>

eg: cd /etc/var
This command changes the present working directory to /etc/var

pwd: This command shows the present working directory.

syntax: pwd
eg: pwd

mkdir: This command is used to make a new directory

syntax: mkdir <directoryname>

eg: mkdir newdirectory
This command will create a new directory on present working directory.
eg: mkdir /home/newdirectory
This command will create a new directory in home directory.

ls: This command is used to list all the files and directories in pwd.

syntax: ls [option]

eg: ls -l
this command will list all the files and folders in the pwd.

rm: This command is used to remove  a file or folder.

syntax: rm [option]

eg: rm -rf log.txt
this command will delete log.txt

mv: This command is used to move or rename a file or folder from source to destination

syntax: mv <source file> <destination file>

eg1: mv log.txt /vishnu
this command will move log.txt to the folder vishnu  
eg2: mv log.txt log2.txt
this command will rename the file from log.txt to log2.txt

Comments

Popular Posts