linux command part-1

 Linux Commands session 1

        ===================================








date and calendar commands
============================


date (gives todays date)
cal (gives calendar of current month)
cal -y (gives calendar for current year)
cal 2018 (will give calendar for year 2018)
cal 2 1993 If you want to view the calendar of February 1993 
clear or ctrl + l to clear the screen
exit






Linux File System
====================


it has a tree like structure


in windows we say as folder however in linux we say as directory.


The first directory (top most) in our directory tree is called the root directory.
It is represented by a forward slash /


each user is given a home directory.


Under each directory , we have two special directories
(1) The current directory represented as . 
(2) The parent directory represented as .. 


An absolute path begins with the root directory and follows the directory tree branch by branch 
until the path to the desired directory or file is completed.
Example
/home/john/documents/phone.txt


A relative path starts from the current working directory.
Example
if our current working directory is john 
then ./documents/phone.txt is relative path of the file phone.txt


● The root directory is represented as / 
● The home directory is represented as ~
● The current directory is represented as .
● The parent directory is represeted as .. 
● The previous directory is represented as ­-




Navigating using cd


Using ls to list




ls command options
==================
ls ­-a
This will list all the files in your current working directories including hidden files that start with .


ls ­-l
That's a long listing It shows many important information about a file. 
Permissions,Number of Links,Owner,Group,File size,Modification Date,File name


ls ­-t This will list the files sorted by modification date. Newest first 


ls ­-r This will list the files in reversed fashion.


ls ­-R


For example, Imagine if you have a directory named dir1 on your desktop, and inside dir1 you have a subdirectory named dir2.
Now, if you type ls ­-R dir1, Then this will list the contents of dir1 and dir2.
if dir2 has another subdirectory dir3 then ls ­-R dir1 will also list the files of dir3 and so on.


if you executed ls ­-R / 
then this will list all the files (non hidden) on your system


combining commands
====================


if you want to list all the files including hidden files on your system ?
● You can just combine the ­-a option with the ­-R option as follows.
● ls ­-R ­-a 
● An easier way is ls ­-Ra 
or ls -aR


ls ­-latR / will make a long listing of all the files on your system sorted 
by modification date (newest first).


If you want to list the files in reverse order based on time Then we can combine ­-r and ­-t so , ls ­-tr will list the files sorted by modification date (Oldest first)

Comments

Popular posts from this blog

scala-4