Unix Concepts

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Unix Concepts

VLSI Services & Solutions


Agenda
• Unix introduction
• File and Directories
• Unix commands
• Shortcuts
• PIPE and redirecting input and output
• Processes associated with the current shell
• Filters
• Shell Variable
• Meta-character

Confidential & Proprietary siliconus.com 2


UNIX Introduction
Unix is family of operating system which has following features:
• Multiuser
• A single copy of OS installed on single disk can be accessed by many users.
• Multitasking
• Unix is a powerful multitasking OS, Unix handles the active and background process efficiently and manages system resources
based on fair-share manner.
• Programing interface
• Unix has a simple user interface called as shell which offer a strong programming platform.
• Security Feature
• Unix has greater build-in security and permission features than other OS.
• Mostly open source:
Eg: linux

Confidential & Proprietary siliconus.com 3


Terminal
• A terminal is gui window through which unix commands can be executed.
• To open a window right click mouse and select terminal.

Unix shell
• Shell is command-line interpreter for unix.
• It gathers input commands from user and executes programs based on inputs.
• Most popular shell are:
• csh
• Bash
• Shell script is a collection of unix commands that are written in a file, and widely for automation in professional world.
File and Directories
• Unix allow “files” and “directories” creation.
• A directory is like a folder, it contains pieces of paper, or files.
• A large folder can even hold other folders-directories can be inside directories.
• Each file each directory has a name eg: lets create file test in home.
• The short name for a file is test,
• The full name would be /home/temporary/test.
• The full name is usually called the path.
Files and Directories
• For example, here is how /home/temporary/test is read as:

/home/temporary/test

This initial slash indicates the root directory. This signifies the
directory called home. It is inside the root directory.

The second slash corresponds to the directory temporary,


which is inside home

Test file is inside temporary directory


File Commands
File command- ls option
Unix commands
• Unix commands are case-sensitive, i.e., a command cat and Cat are
different.
• All unix internal commands are lower case.
• Commands may be followed by arguments eg: ls [dir_name]

• Key that probably you will use the most is TAB


• To see linux command press TAB
• If you want to see commands with c, write c on command prompt and presss
TAB
• TAB is used for Auto complete
Unix commands- System info
Unix commands- permissions
• Type of permission:
• Read
• Write
• Execute
• Each of these permissions can be toggled separately for the owner,
the group, and all the other users.
• #ls –lrta temporary
Unix commands- permissions

• Here, the first column represents different access modes, i.e., the permission associated with file or a directory.
• The permissions are broken into groups of threes, and each position in the group denotes a specific permission, in this
order: read(r), write (w), execute (x)
• The first three characters (2-4) represent the permissions for the file’s owner. For example, -rwxr-xr– represents that the
owner has read(r), write(w), execute(x) permission
• The second group of three characters (5-7) consists of the permissions for the group to which the file belongs. For
example, -rwxr-xr– represents that the group has read read(r) and execute(x) permission, but no write permission.
• The last group of three characters (8-10) represents the permissions for everyone else. For example –rwxr-xr– represents
that there is Read(r) only permission.
Unix commands- permissions chmod
• Chmod
• Change mode
Shortcuts
PIPE and redirecting input and output
• Pipe
• You can connect two commands together so that the output
from one program becomes the input of the next program. Two
or more commands connected in this way from a pipe.
• To make a pipe, put a vertical bar (|) on the command line
between two commands.
• Eg:# cat hello.txt | sort | uniq
• Creates three processes (coreesponding to cat, sort and
uniq) which execute concurrently. As they execute, the
output of the whole process is on to the sort process
which inturn passed on to the uniq process, uniq displays
its output on the screen (a sorted list of users with
duplicate lines removed)
• Semicolon ; is used to execute many commands sequentiallay
• Echo “siliconus ” ; cd /home/temporary ; gvi test
• The output from programs is usually written
to the screen and called as standard output
• The input of a program is usually comes from
the keyboard and called as standard input.
Processes associated with the current shell

• Jobs can be either be in the foreground or the background.


• There can be only one job in the foreground at any time. The foreground job has control of the shell with which you
interact.
• The foreground job may be suspended, i.e. temporarily stopped, by pressing the Ctrl-Z key. A suspended job can be
made to continue running in the foreground or background as needed by typing “fg” or “bg” respectively.
• Background jobs can also be run directly from the command line, by appending a ‘&’ character to the command line.
Filters
Shell Variable
• Types of variable:
• User variable
• Local
• Environment
• System Variable, eg: $HOME, $PWD, $SHELL
• No Type declaration and initialization is required in SHELL variables.
• In csh set command is used for setting a user’s local variable.
#set count = 100
#echo $count
100
• Command setenv is used to define environment variable.
#setenv count 100
#echo $count
100
#tcsh
#echo $count
100
Meta-character
• Metacharacters are a group of characters
that have special meanings, not literal
meaning, to the UNIX
• They can make many tasks easier by
allowing you to
• Redirect information from one
command to another or to a file
• String multiple commands together
on one line
Meta-character
Thank You

Confidential & Proprietary siliconus.com

You might also like