EVERYTHING IN COMMAND LINE/ TERMINAL – MANIPULATION

Here, we learn about Manipulation of Files and Directories. For manipulation we use options.

  • ls -a = lists all files and directories including the hidden ones. Here, -a is an option.
pwd
/home/all/wild
  • ls -a = lists all files and directories including the hidden ones. Here, -a is an option. The hidden directories or files begin with a dot (.).
ls
animals  birds  flowers.txt
ls -a
. .. .local animals birds flowers.txt
  • ls -l = The -l option lists files and directories as a table. The -l option lists files and directories as a table.Here we see three rows, with seven columns separated by spaces. Here’s what each column means:
    1. Access rights. These are actions that are permitted on a file or directory.
    2. Number of hard links. This number counts the number of child directories and files. This number includes the parent directory link (..) and current directory link (.).
    3. The username of the file’s owner. Here the username is company.
    4. The name of the group that owns the file. Here the group name is staff.
    5. The size of the file in bytes.
    6. The date & time that the file was last modified.
    7. The name of the file or directory.
ls -l                                                                                       
total 8                                                                                     
drwxr-xr-x 4 company staff 4096 Jul  8 17:33 animals                                          
drwxr-xr-x 4 company staff 4096 Jul  8 17:36 birds                                                                                      
-rw-r--r-- 1 company staff    0 Jul  8 17:32 flowers.txt     
  • ls – t = lists all files and directories in the order of last modified. :
ls -t
birds animals flowers.txt
  • ls – alt = lists all files and directories including hidden ones, in long format, ordered by the date and time they were last modified.
ls -alt                                                                         
total 20                                                                          
drwxr-xr-x 5 company staff 4096 Aug 16 01:54 ..                                   
drwxr-xr-x 4 company staff 4096 Jul  8 17:57 .                                    
-rw-r--r-- 1 company staff    0 Jul  8 17:42 .local                           
drwxr-xr-x 2 company staff 4096 Jul  8 17:36 birds                               
drwxr-xr-x 2 company staff 4096 Jul  8 17:33 animals                            
-rw-r--r-- 1 company staff    0 Jul  8 17:32 flowers.txt 
  • cp <files or directories to copy> <destination> = used to copy files or directories to specified destination

cp biopic/ray.txt biopic/notorious.txt historical/

Advertisements

Everything in Command Line/ Terminal – Navigation

Here, we learn about Navigating through Directories using the Command Line

searchforterminal

 

  • pwd = print working directory
pwd
/home/all/wild
  • ls = list : lists all folders/files in working directory
ls
animals  birds  flowers.txt
  • cd <directory> = change directory :

Moving to an internal directory
provide name of the folder to move to a directory within the current directory , example – ‘cd animals’ will move directory to path /home/all/wild/animals

cd animals
pwd
/home/all/wild/animals

Moving to an external directory(outside the current working directory : provide the path)

cd /home/all/domestic/birds
pwd
/home/all/domestic/birds

Moving to one directory up or one step back

cd ..
pwd
/home/all/domestic

mkdir <directory_name> = make a new directory :

Make a new directory within the working directory

mkdir cattle
pwd
/home/all/domestic
ls
cattle fish friendly.txt

Make a new directory outside the working directory
Here, making directory ‘cuckoo’ under birds in wild.

mkdir /home/all/wild/birds/cuckoo
cd /home/all/wild/birds
ls
cuckoo parrot.txt

touch <filename> = creates a new file :

Create a new file in current working directory

pwd
/home/all/wild/birds
touch owl.txt
ls
cuckoo parrot.txt owl.txt

Create a new file in outside working directory

touch /home/all/wild/animals/lion.txt
cd /home/all/wild/animals
ls
lion.txt