TCSH

TCSH Commands

  1. echo $0 = Prints which shell we are working in.

  2. which<command/shell> = Prints the absolute path of the installed location of the shell or the command.

  3. To install any package: apt install <package name>

Eg: apt install tcsh

Sudo  install –y <package>

Eg: sudo install –y tcsh

  1. To change from one shell to other shell we just need to type the shell name.

  2. Knowing present working directory

PWD: This command gives the absolute path of the directory we are working in.

  1. Changing to another directory : cd

Syntax: cd <path of the directory where we want to change>

Cd - : it will change to the last opened directory.

  1. Creating an empty file: touch

Syntax: touch <filename>

  1. Creating a directory: mkdir

Mkdir means make directory; it creates an empty directory.

Syntax: mkidr<directoryname>

Mkdir –p directory1/directory2 : This creates a directory2 inside directory1 at one go with the help of option –p ( -p: parent).

  1. Concatenate command: 

The command for concatenate is “CAT”

This command helps in creating a file, displaying a file, writing content into a file, concatenating a file.

Cat >filename : this command creates a file if it does not exist and prompt blinks in next line expecting to add some information to the file. If a file exists the previously existing data will be overwritten by the new content.

Cat >>filename : this command creates a file if it does not exist and prompt blinks in next line expecting to add some information to the file. If a file exists the new content will be appended to the existing data.

Cat filename :  this command only displays the content of the file in the terminal.

Cat –n filename : this command displays the line number and content of the file in the terminal.

  1. Redirectory operators:

>, < ,>> these symbols are called as redirectory operators.

  • > : outputredirectory operator. This displays content of a file but not in the terminal the content is redirected to other file and one can view it by opening that file.

If content does not exist in a file it adds but If data is already present it will overwrite.

Syntax : command > command/filename

Eg: cat > filename

Eg: echo “ hello” > file

  • >> : output redirectory operator. It works as the previous one but it does not overwrite the content it will append.

Syntax: command >> argument

Eg: cat >> filename

  • < : input redirectory operator. The output of one command is given as input to the next command.

Syntax: command <argument>< command <argument>

Eg: cat file < sort file : this sorts the content of the file and this sorted file is an input to the cat command and displays sorted data in the terminal.

touch cat pwd.PNG



  1. Listing command: ls

This command lists out all the files and directories in the current directory or if the path is specified it displays the all the directories and files of that particular directory.


Syntax: ls or ls /path of required directory/

Eg :ls ./ or ls ../ orls ~


ls –a : It displays all the hidden files in the directory.

Note: A hidden file is represented with .filename; to create a hidden file : touch .filename

ls –l : It is long listing command which displays as :

-/drw-r--r--  volumeuserID size month date time filename ; - : file ; d : directory

Eg : -rw-r- -r- - 1 userID 4098 jan 1 12:08 filename : This is a file with 1 as a volume by a user with 4098byte created on jan 1 12:08.  


Eg: drw-r- -r- - 2 userID 4098 jan 1 12:08 directory : This is a directory with 2 directories or files inside by a user with 4098byte created on jan 1 12:08.  

ls –tl : displays long listing output with recently created on the top.

ls –rtl: displays long listing output with recently created on the bottom.

Note: t = time; r = reverse.

ls.PNG

  1. Quotes:

Eg: set a = 10

Set b = 5

Echo ‘$a,$b’ : output: 10,5

Echo “$a,$b” : output: $a,$b

Set c = `expr $a + $b` : output: 15 

` `: command substitution

“ “ : masking

‘ ‘ : to access the variables

  1. Tail and Head: It is used to print last 10 lines and 1st 10 lines of a file respectively.

Tail file: it prints last 10 lines of file

Tail -5 file: it prints last 5 lines of file

Head file: it prints 1st 10 lines of file

Head -4 file: it prints 1st 4 lines of file

  1. Pipeline operator: |

It is used to cascade the multiple commands.


C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.55 PM (1).jpeg


  1. Unix files colors :-

Blue or Dark Blue – Directory

Green – Executable or recognized data file

Sky Blue – Linked file

Yellow with Black background – Device

Pink – Graphic Image file

Red – Archive file or Zip file

  1. Copying a file or directory : cp

Syntax: cp /sourcepath/ /destinationpath/

We can copy a file or directory using this command. To copy a directory we need to use –r option which means recursive so that all the files and directories inside that directory will be copied. Once a file or directory is copied it will leave the copy behind and gets pasted in the new location also.

Eg: cp –r /home/user/directory/ ./

Eg: cp /home/user/directory/file ./


  1. Moving or renaming a file or directory: mv

Syntax: mv /sourcepath/ /destinationpath/ : to move

Syntax: mv /existing file or directory name/ /renaming file or directory name/ : to rename

This command will delete the copied file or directory in its original location and pastes in the new location. To move a directory we need to use –r option which means recursive so that all the files and directories inside that directory will be moved.

Eg: mv –r /home/user/directory/ ./

Eg: mv /home/user/directory/file ./

Eg: mv /home/user/directory/file1 /home/user/directory/file.txt

  1. Deleting a file or a directory: rm

Syntax: rm /path of a file or directory/

This command will permanently delete the file or directory and we cannot find it in trash bin or anywhere else in the system. To delete a directory we need to use –r option which means recursive so that all the files and directories inside that directory will be delete.

rm –I file/directory : the prompt asks if we are sure about deleting that particular file or the directory before deleting so that one can avoid wrong deletion. 

cp.PNG

  1. Link: It acts like a string creating pathways for different files and directories in the computer system. These are capable of creating and storing multiple files in different places referring to one single file.

There are two types of links: soft link, hard link.

  1. Soft link:  These are the actual copy of the original file. When any changes is done in original file or linked file the changes are affected on both the files. If we delete the original file then the soft linked file will be existing but the content will be erased and the deleted original file will be blinking and soft linked file will appear in red letters in a black background this can be seen when one does ls –l.

Syntax: ln –s [target file] [soft link file name]

S indicates its symbiolic i.e. soft link.

To check if link file is created or not :

ls –l is the command to check, the output of this command will be:

lrw-r- -r- - 1 USERID 4098 month date time linkedfile ->originalfile

The linked file appears in skyblue colour.

Syntax: ln –sv [target file] [soft link file name]

V indicates its verbose.

The output of ln –sv [target file] [soft link file] will be soft link file -> original file ; where soft linked file appears in skyblue colour.

  1. Hard link: These are the mirror copy of the original file. When any changes is done in original file or linked file the changes are not affected on the other file. If we delete the original file then the hard linked file will be existing and the content will also be existing. The hard link file name appears in blue background.

Syntax: ln  [target file] [hard link file name]

To check if link file is created or not :

ls –l is the command to check, the output of this command will be:

lrw-r- -r- - 1 USERID 4098 month date time linkedfile

The linked file appears in blue colour background.

Syntax: ln –v [target file] [hard link file name]

V indicates its verbose.

The output of ln –v [target file] [hard link file] will be hard link file => original file ; where hard linked file appears in blue colour background.

  1. Unlink : This removes the linked file.

Syntax: unlink <linked file name>

C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.56 PM (3).jpeg





  1. Suspend: When we are running some script and it takes more than the expected run time then suspension of that script can be done with the help of “ctrl + z”. The script still remains in the background so if one wants to resume that script then “bg” will help but it will resume only the recent script that has been suspended.

  2. “Command <argument>&“ This will work same as ctrl + z and the bg command. So when one gives this command with & we can continue next script instead of waiting for the executing command.

  3. Fg: foreground command, when one give “fg” command the current running job will showed on the terminal, upon seeing the job one can give bg so that the job still continues in the background.

  4. To kill a current process we can use “ctrl + c”.

  5. Secure shell : ssh

We have to use another server from our server to do our projects and this can be done with help ssh command.

Syntax :ssh –x <user ID @ server name>

It asks for the assigned password, once it is entered we are taken to the server where we wish to work.

  1. To know the current running process : ps (process status).

The output of ps will be:

<PID >< terminal type><time><command>

  1. To kill current active process : kill

Syntax : kill% -9 PID : it forcefully kills the active PID.

  1.  Jobs: This command is used to list all the jobs that you are running in the background and in the foreground. If prompt returns without any information it means no jobs are active. This command only works on Bash, tcsh, ksh and csh shells only.

C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.56 PM (4).jpeg

  1. To know disk information:

Staying in the home directory :df –kh ./ : This gives the disk free area of our system or server.

To get each files disk space utilized information: du –sh * 

To get the information of the complete team’s files utilized area information: du –u *

C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.56 PM.jpeg




  1. To create our own command: alias

Syntax:  alias “our_command=Linux_command”

Eg: alias “c=cd”

  1. To clear the terminal : clear

  2. To send mail from the terminal: mail

Syntax: mail –s “subject” <mail id of receiver><message>

Syntax to send file as a message: mail –s “subject” <mail id of receiver>< filename

Syntax to add cc, bcc and attach file: mail –s “subject” <mail id of receiver> -c <cc mail id> -b < bcc mail id> -a <attachment><message>

Syntax for multiple recipients: mail –s “subject” <mail ID 1 , mail ID2, …><message>

  1. Archive: tar

-cf : to create an archieved folder

-xf : to extract an achieved folder

-rf: to udate any direcory or fie to archieved folder

-tf: to display content of the archieved folder

C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.58 PM (2).jpeg

C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.55 PM.jpeg

  1. To print all the groups that we have access to : id

The output of “id” command will be the accessed group name and their ID.

  1. To get access to any of the existing group: mount

Mount <active group name>

Unless the group member gives permission one cannot get access to that group.

  1. To display all the groups: groups

  2. To display all the groups we are working on: gid

  3. To change our UNIX password: password

  4. Sleep n : n is n seconds that we do not want our terminal to work for. Till the n seconds finish the terminal does not accept any other command entered.

  5. Zip files: 

To compress a file: gzip<filename>

To unzip: gunzip<filename>

To open zipped file: zcat<filename>

C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.58 PM (3).jpeg

  1. To know who is logged in to your system: whoami

  2. To assign a variable: set

Syntax: set <variable> = <value>

To print the value of the variable: echo $varaible

C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.58 PM (1).jpeg

  • File permissions in unix:

When we create a directory or file there are few permissions which are created by default.

For every file or directory there exists read, write and executable permissions.

There are 3 categories user, group and others to whom we give read, write and executable permissions.

By default the permissions to the directory are: rwx,rx,r  .

By default the permissions to the file are: rw,r,r

There are two methods to change the permission to a file or directory: octal method, variable method.

Octal method: It uses 8421 code representation.

Rwx has 8 combinations to be represented.

---: 0

--x: 1

-w-: 2

-wx: 3

r--: 4

r-x: 5

rw-: 6

rwx: 7

For user, group and others this has to be represented.

Variable method: It uses +,-,= to add, remove and assign the permission.

U+w: it adds write option to user

G=wx: it over writes write and executable option to the group

o-x: It removes executable option from others.

The command to change the permissions: chmod

Syntax: chmod<octal/variable notation> file/directory

Eg: I would like to assign user with all permissions, group with read and write permission and others with only read permission using octal method.

Chmod 764 file

Eg: I would like to assign user with all permissions, over writing the  write permission to group and others with only read permission by removing write and executable permission using variable method.

Chmod u+rwx,g=rw,o-wx file

C:\Users\manas\Downloads\WhatsApp Image 2023-01-19 at 4.21.56 PM (1).jpeg


 

Comments

Popular posts from this blog

PERL scripting

SHORT CHANNEL DEVICE

Introduction to CMOS inverter