Monday, 2 November 2026

Unix Commands

Unix Commands 

 

1) clear - to clear up your shell 
 
2) echo "Welcome"
 
3) pwd - print the working directory
 
4)  cd - change directory
 
5) ls - list of files and folders
 
6) cd ..  - which changes the working directory to the folder above the current working directory 
 
7) cd ~  -  takes you to your home directory. 
 
8) mkdir  - make a directory
 
9) touch - create a blank file 
 
10) ls -l   - long listing of files in a directory
 
11)  wc <filename> - word count in a file (displays the number of lines in a file followed by the number of words and then the number of characters.)
 
12) cat <filename> - print text files to the terminal
 
13)  less <filename> - large file we should use less, which is a program designed for viewing multi-page files.
(use the spacebar to go to the next page and the b key to go to the previous page. In order to quit less and go back to the prompt press the q key.) 
 
14) head  <filename> - head prints the first ten lines of the file to the terminal. 
 You can specify the number of lines printed with the -n option followed by the number of lines you’d like to see:   head -n 4 <filename> (prints first four line)
 
15)  tail <filename> - tail prints the last ten lines of the file to the terminal. 
tail -n 15 <filename> (prints last 15 lines)
 
16) echo "Welcome to my page"  > test.txt - a file name test.txt has created with the content Welcome to my page. if we cat it, it will be like
cat test.txt 
Welcome to my page

17) echo "Lets add few more details"  >> test.txt we can also append text to the end of
a file using two greater-than signs (>>).
cat test.txt 
Welcome to my page
Lets add few more details
  

 

Notes

  • The root directory (/) contains all of the folders and files on your computer. 

Friday, 21 March 2025

Unix: Vi Editor Commands (CheatSheet)

 Opening and Exiting vi

  • vi filename   ->   Open a file
  • :q!   ->   Quit without saving
  • +wq!   ->   Save and quit
Switching Modes
  • esc   ->  exit to command mode
  • i   ->   insert mode (insert before cursor)
  • I   ->  insert at beginning of line
  • a.  ->  append after cursor
  • A  ->  append at end of line
  • o   ->  open a new line below
  • O  ->  open a new line above
Navigation
  • h   ->  move left
  • l    ->  move right
  • j    ->  move down
  • k   ->  move up
  • 0   ->  move to beginning of line
  • ^   ->  move to first non-blank character
  • $   ->  move to end of line
  • w  ->  jump to next word
  • b   ->  jump to previous word
  • gg ->  go to beggining of file
  • G  ->  go to end of the file
  • :n  ->  go to line number n
Editing and Deleting

  •  x    ->   delete a character
  •  dw  ->  delete word
  •  dd   ->  delete entire line
  •  D    ->  delete from cursor to end of the line
  •  u     ->  undo last action
  •  r     ->  replace single character
  •  yy   ->  copy entire line where the cursor is currently located
  •  p     ->  paste after cursor
  •  P     ->  paste before cursor

Search and Replace

  • /text  ->  search forward for text
  • ?text  ->  search backward for text
  •   n    ->  repeat search word forward
  •   N   ->  repeat search word backwards
  •  :%s/old/new/g  ->  replace all occurrences of old with new
  • :set nu  ->  show line numbers


Sunday, 30 June 2024

Grade 6 : Algebra - Expression - Example problem

1) Which expression represents 5 more than the product of 2 and  y ?

Solution

Product of 2 and y is  2*y or 2y

 5 more than the product of 2y is 2y + 5 or 5 + 2y

---------------------------------------------------------------------------------------


2) Which value of b makes the inequality 3b > 12 true?

a) 2           b)3          c)4          d)5

Solution

Lets assume b=2

Replace b by 2 in 3b > 12

                          3*2 > 12

                           6 > 12 ( which is not true because 6 < 12)

Lets assume b=3

Replace b by 3 in 3b > 12

                          3*3 > 12

                           9 > 12 ( which is not true because 9 < 12)

Lets assume b=4

Replace b by 4 in 3b > 12

                          3*4 > 12

                           12 > 12 ( which is not true because 12 = 12)

Lets assume b=5

Replace b by 5 in 3b > 12

                          3*5 > 12

                           15 > 12 (yes, 15 is greater than 12 which is true)

Answer is d) 5







Saturday, 8 June 2024

Grade 7 - Math - Algebra Word problem

The cost of renting a movie is $1.59 for the first two days $0.50 for every day after two days. If Rosy rented a movie and kept it for a week, how much money will she have to pay?

Solution

No.of days Rosy kept the rented movie = 7days (a week)

Cost for the first two days = $1.59
Cost for the remaining 5days = 5*$0.50 
                                           = $2.50

Total amount Rosy has to pay for the rented movie = $1.59 + $2.50 

                                                                          = $4.09




Saturday, 25 February 2023

RHCSA Exam Notes : Hard and Soft link in Unix/Linux

 Create Hard links:

Command:

The below command created hardlink called file1.txt for the existing file trial1.txt in /home/student

ln file1.txt /home/student/trial1.txt

Create Soft link:

Command:

The below command created soft link called file1.txt for the existing file trial1.txt in /home/student

ln -s file1.txt /home/student/trial1.txt


Monday, 20 February 2023

Red Hat Certified System Administrator(RHCSA) Exam - Key points(Notes)

 list command in unix : ls

ls

It will show the full list or content of your directory

 

ls -a

In Linux/Unix, hidden files start with . (dot) symbol and they are not visible in the regular directory. The (ls -a) command will enlist the whole list of the current directory including the hidden files.

 

 ls -l

It will show the list in a long list format. 

 

Column 1 : indicates information regarding file permission.
Column 2 : indicates the number of links to the file.
Column 3 & 4 : indicates the owner and group information.
Column 5 : indicates the file size in bytes.
Column 6 : shows the date and time on which the file was recently modified.
Column 7 : shows the file or directory name.

 

ls ~

ls ~ command shows the contents of the home directory

 

 

ls -g

If we don't want to display the owner information in your list, then we can exclude this column with the help of this command. 

 

 

ls -lrt

The ls command is used for listing the contents of a directory. The lrt part is a combination of three different options:

  • l: This is for the long listing of the contents. It shows one file in each line with additional info such as permissions, ownership, size, timestamps etc.
  • t: This one sorts the long listing output based on time.
  • r: This one reverses the order of ls command output.

 

 

 

ls -n

It is used to print group ID and owner ID instead of their names.

 

 

 ls -li

This command prints the index number if file is in the first column.

 

 

 ls -p

It is used to identify the directory easily by marking the directories with a slash (/) line sign.

 

 

ls --version

It checks the version of ls command.