For each file any users can be classified into any of the three categories:
• u – User / Creator of the file
• g – Group User
• o – Any other user
ls -l gives a detailed listing along with the user and privilege details.
There are separate privileges for read(r), write(w) and execute(x) for user, group
user and other users.
chmod : Used to change the user privileges of any file.
Use -r or –recursive to apply privileges excursively to all subfiles in a directory.
Eg: chmod u+x abc.txt #Add user the privilege to execute.
chmod ug+rwx abc.txt #Add user and group user the privilege to read,write andexecute.
chmod o-x abc.txt #Deducing the power of other user to execute the file.
chmod 777 abc.txt #Give all privileges to all categories of users.
Processes:
A program executing in memory is called a process.
Using a terminal we can execute a process in:
• Foreground
OR
• Background
<regular_command> : Runs the command in background.
<regular_command> & :Runs the command in background.
jobs :Command to display all the jobs running in background.
Ctrl + Z :Suspends a program running in foreground.
Ctrl + C :Terminate and quit a process running in foreground.
%n :Every process running in background has got a unique number, we can get that
using job command.
bg <%n> :Reactivate a suspended program in background.
fg <%n> :Puts the job back in background.
kill <%n> :Terminates a background process.
• All the process has got a unique identification number called PID or Process ID.
• A process is being created by another by the process of forking in which the address space of
one process is being cloned.
• Every process also have a Parent Process Id or PPID.
ps : Displays the processes created by the current user.
-f : Option to display PPID as well.
-e or -A : Display all the system process as well.
-u
Eg:
ps -e | grep tty
ps -e
kill <PID> :Terminates a process.
top : Displays the currently running tasks and their CPU utilization.
nohup
output to the file nohup.out.
Eg: nohup wget -c www.athena.nitc.ac.in/file.txt &
NB: wget is used to download a file.
pstree : Displays all currently running processes along with their parent child relationships.
time
netstat :Displays the current network usage and traffic.
vmstat : Displays the current virtual memory usage.
sleep <seconds> :Do nothing for sometime.
Eg: sleep 5
(sleep 1800 ; echo “Lunch Time”) &
I/O Redirection:
> : Used to direct the output to a file.
>> : Used to append the output to a file.
| : Used to take the output of one command to another.
Eg: ls -al > ls.list
top > current.txt
Package Managers:
1.Redhat Package Manager : RPM
installing an rpm:
rpm -Uvh
-U : Upgrade
-v : Generate more verbose output
-h : Gives a progress bar of installation
To check whether a program is being installed:
rpm -qa | grep gimp
Uninstalling:
rpm -e application
2.Debian Package Manager : dpkg
To install an application:
sudo dpkg -i package.deb
To check version and details of an installed application:
dpkg -l application
OR
dpkg -l *application*
3.APT – Advanced Package Manager
sudo apt-get update : Will update the database with list of available packages
sudo apt-get install package : Installs a new package.
sudo apt-get upgrade : Performs and upgrade.
ssh user@host : Secure Shell Login to a remote server
scp sort.cpp abijith_bcs10@athena.nitc.ac.in: : SSH File Copy
write user [tty] : Used to send messages to other users.
Using gcc:
gcc-o
./output_filename
Different Shells:
sh : Traditional Unix Shell or Bourne Shell
bash : Bourne Again Shell, the default linux shell
ksh : Korn Shell
csh : C-Shell
tcsh : Turbo C Shell
$SHELL : Environment variable that contains the current shell.
etc/shells - File containing the list of available shells.
Shell scripts starts with
#! /bin/bash
so that when they are executed, it will be using BASH by default.
Eg:
#! /bin/bash
echo “Hello World!..”
Save it as sample.sh and give chmod +x sample.txt
Execute it as: ./sample.sh
Go To :
Linux Basic Command Part [1/3] << GO TO
Linux Basic Command Part [2/3] < PREVIOUS
Linux Basic Command Part [3/3]
Done :)