SlideShare a Scribd company logo
UNIX C Shell Cheat Sheet
Setup
File Manipulation
Terminal Setup % stty erase ‘^?’ kill ‘^U’ intr ‘^C’
% set term=vt100
Setting Path Variable % set path=(directory ... directory)
Password Changing % passwd
Changing Default
Shell
% chsh
Help % man command
% man -k topic
Logging Out % logout
% <CTRL-D>
Listing Files % ls
Displaying Files % cat filename
% more filename
<space> next page
<return> next line
q quit
Copying Files % cp file1 file2
% cp file1 [file2] ... directory
% cp -r directory1 directory2
Use the -i option to prompt before overwriting files.
Moving Files % mv file1 file2
% mv file1 [file2] ... directory
% mv directory1 directory2
Use the -i option to prompt before overwriting files.
Removing Files % rm filename
% rm -r directory
Use the -i option to prompt before deleting files.
Printing Files % lpr filename
Directory Manipulation
Miscellaneous Commands
File Protection
Creating Directories % mkdir directory
Changing Directories % cd directory
% cd
Displaying Current
Directory
% pwd
Removing Directories % rmdir directory
Finding Files % find directory -name filename -print
Searching Files % grep string filename
Sorting Files % sort [-o output-file] filename
Comparing Files % diff filename1 filename2
% cmp filename1 filename2
User and Permission
Types
u file owner (u is short for user)
g group members
o all other users
r read permission
w write permission
x execute permission (for directories, allows users to use
the directory name in a pathname)
Displaying File
Protection
% ls -l filename
Changing File
Protection
% chmod [ugo][+-=][rwx] filename
% chmod nnn filename
numeric protection mode table
user group other
r 400 40 4
w 200 20 2
x 100 10 1
Default Protection % umask nnn
The umask value is subtracted from 666 for new files and
from 777 for new directories.
I/O Redirection
C Shell Specific Commands
Input Redirection % command < filename
Output Redirection
(overwrite)
% command > filename
Output Redirection
(append)
% command >> filename
Error Redirection
(overwrite)
% command >& filename
Error Redirection
(append)
% command >>& filename
Noclobber Variable % set noclobber
Setting the noclobber variable protects files from being
accidentally overwritten due to output redirection (but not
cp, mv, etc.). “!” following any redirection operator over-
rides noclobber.
Piping Operator % command1 | command2
Enable Tracking of
Commands
% set history=n
Displaying Com-
mand History
% history
Re-executing Previ-
ous Commands
!! previous command
!n nth command
!string last command beginning with string
!-n nth most recent command
!?string? last command containing string
Saving Command
History
% set savehist=n
Setting Aliases % alias alias-string command-string
Displaying Aliases % alias
Deleting Aliases % unalias alias-string
Special Files
Job Control
.cshrc This file, if it exists in your home directory, is automatically
executed at login. Must begin with “#” to indicate C shell
script.
.cshrc typically includes C shell specific commands such
as the set noclobber, set history, set savehist,
and alias commands.
.login This file, if it exists in your home directory, is automatically
executed at login. Must begin with “#” to indicate C shell
script.
.login typically contains generic UNIX commands such
as the stty, set path, and umask commands.
.logout This file, if it exists in your home directory, is automatically
executed at logout. Must begin with “#” to indicate C shell
script.
.logout typically contains commands to perform cleanup.
Running Jobs in the
Background
% command &
Stopping Foreground
Jobs
% command
.
.
.
<CTRL-Z>
%
Job Status % jobs
Killing Jobs % kill %job-number
% kill process-id
Bringing Jobs to the
Foreground
% fg %job-number
Moving Jobs to the
Background
% bg %job-number
Process Status % ps lists all your processes
% ps -a lists all running processes
% ps -x full listing for given option
Displaying Users % who
% whoami

More Related Content

What's hot (20)

Introduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
Linux shell scripting
Linux shell scripting
Mohamed Abubakar Sittik A
 
Shell Scripting
Shell Scripting
Gaurav Shinde
 
lec4.docx
lec4.docx
ismailaboshatra
 
Shell scripting
Shell scripting
Geeks Anonymes
 
Pipes and filters
Pipes and filters
bhatvijetha
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Zyxware Technologies
 
Unix Shell Scripting Basics
Unix Shell Scripting Basics
Sudharsan S
 
Unix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scripting
Dan Morrill
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)
Lin Yo-An
 
Shell programming 1.ppt
Shell programming 1.ppt
Kalkey
 
Linux shell env
Linux shell env
Rahul Pola
 
Unix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
Lingfei Kong
 
Unix shell scripting
Unix shell scripting
Pavan Devarakonda
 
Memory Manglement in Raku
Memory Manglement in Raku
Workhorse Computing
 
Shellscripting
Shellscripting
Narendra Sisodiya
 
Using the Command Line with Magento
Using the Command Line with Magento
Matthew Haworth
 
KubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume Plugins
KubeAcademy
 
Introduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
Pipes and filters
Pipes and filters
bhatvijetha
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Zyxware Technologies
 
Unix Shell Scripting Basics
Unix Shell Scripting Basics
Sudharsan S
 
Unix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scripting
Dan Morrill
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)
Lin Yo-An
 
Shell programming 1.ppt
Shell programming 1.ppt
Kalkey
 
Linux shell env
Linux shell env
Rahul Pola
 
Unix Shell Scripting Basics
Unix Shell Scripting Basics
Dr.Ravi
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
Lingfei Kong
 
Using the Command Line with Magento
Using the Command Line with Magento
Matthew Haworth
 
KubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume Plugins
KubeAcademy
 

Similar to Unix cheatsheet (20)

unix_ref_card.pdf
unix_ref_card.pdf
GiovaRossi
 
unix_ref_card.pdf
unix_ref_card.pdf
GiovaRossi
 
unix_ref_card.pdf
unix_ref_card.pdf
GiovaRossi
 
Unix
Unix
Sudharsan S
 
QSpiders - Unix Operating Systems and Commands
QSpiders - Unix Operating Systems and Commands
Qspiders - Software Testing Training Institute
 
Unix and Linux - The simple introduction
Unix and Linux - The simple introduction
Amity University Noida
 
Linux Commands all presentation file .pptx
Linux Commands all presentation file .pptx
AshutoshPrajapati30
 
Linux System commands Essentialsand Basics.pptx
Linux System commands Essentialsand Basics.pptx
mba1130feb2024
 
Presentation aix basic
Presentation aix basic
xKinAnx
 
basic-unix.pdf
basic-unix.pdf
OmprakashNath2
 
UNIX Command Cheat Sheets
UNIX Command Cheat Sheets
Prashanth Kumar
 
Unix3
Unix3
Krishna Prasad
 
Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
Linux cheat sheet
Linux cheat sheet
Pinaki Mahata Mukherjee
 
8.1.intro unix
8.1.intro unix
southees
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS
 
Directories description
Directories description
Dr.M.Karthika parthasarathy
 
Linux cheat sheet
Linux cheat sheet
Dimitris Kyrgiafinis
 
58518522 study-aix
58518522 study-aix
homeworkping3
 
Unix tutorial-08
Unix tutorial-08
kavitha_tala
 
Ad

Recently uploaded (20)

How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
NALCO Green Anode Plant,Compositions of CPC,Pitch
NALCO Green Anode Plant,Compositions of CPC,Pitch
arpitprachi123
 
TEA2016AAT 160 W TV application design example
TEA2016AAT 160 W TV application design example
ssuser1be9ce
 
4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...
ijait
 
Understanding Amplitude Modulation : A Guide
Understanding Amplitude Modulation : A Guide
CircuitDigest
 
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
samueljackson3773
 
IntroSlides-June-GDG-Cloud-Munich community [email protected]
IntroSlides-June-GDG-Cloud-Munich community [email protected]
Luiz Carneiro
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
The first edition of the AIAG-VDA FMEA.pptx
The first edition of the AIAG-VDA FMEA.pptx
Mayank Mathur
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
NALCO Green Anode Plant,Compositions of CPC,Pitch
NALCO Green Anode Plant,Compositions of CPC,Pitch
arpitprachi123
 
TEA2016AAT 160 W TV application design example
TEA2016AAT 160 W TV application design example
ssuser1be9ce
 
4th International Conference on Computer Science and Information Technology (...
4th International Conference on Computer Science and Information Technology (...
ijait
 
Understanding Amplitude Modulation : A Guide
Understanding Amplitude Modulation : A Guide
CircuitDigest
 
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-ABB Furse.pdf
djiceramil
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODS
samueljackson3773
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
Tree_Traversals.pptbbbbbbbbbbbbbbbbbbbbbbbbb
RATNANITINPATIL
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
The first edition of the AIAG-VDA FMEA.pptx
The first edition of the AIAG-VDA FMEA.pptx
Mayank Mathur
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
SEW make Brake BE05 – BE30 Brake – Repair Kit
SEW make Brake BE05 – BE30 Brake – Repair Kit
projectultramechanix
 
Ad

Unix cheatsheet

  • 1. UNIX C Shell Cheat Sheet Setup File Manipulation Terminal Setup % stty erase ‘^?’ kill ‘^U’ intr ‘^C’ % set term=vt100 Setting Path Variable % set path=(directory ... directory) Password Changing % passwd Changing Default Shell % chsh Help % man command % man -k topic Logging Out % logout % <CTRL-D> Listing Files % ls Displaying Files % cat filename % more filename <space> next page <return> next line q quit Copying Files % cp file1 file2 % cp file1 [file2] ... directory % cp -r directory1 directory2 Use the -i option to prompt before overwriting files. Moving Files % mv file1 file2 % mv file1 [file2] ... directory % mv directory1 directory2 Use the -i option to prompt before overwriting files. Removing Files % rm filename % rm -r directory Use the -i option to prompt before deleting files. Printing Files % lpr filename Directory Manipulation Miscellaneous Commands File Protection Creating Directories % mkdir directory Changing Directories % cd directory % cd Displaying Current Directory % pwd Removing Directories % rmdir directory Finding Files % find directory -name filename -print Searching Files % grep string filename Sorting Files % sort [-o output-file] filename Comparing Files % diff filename1 filename2 % cmp filename1 filename2 User and Permission Types u file owner (u is short for user) g group members o all other users r read permission w write permission x execute permission (for directories, allows users to use the directory name in a pathname) Displaying File Protection % ls -l filename Changing File Protection % chmod [ugo][+-=][rwx] filename % chmod nnn filename numeric protection mode table user group other r 400 40 4 w 200 20 2 x 100 10 1 Default Protection % umask nnn The umask value is subtracted from 666 for new files and from 777 for new directories.
  • 2. I/O Redirection C Shell Specific Commands Input Redirection % command < filename Output Redirection (overwrite) % command > filename Output Redirection (append) % command >> filename Error Redirection (overwrite) % command >& filename Error Redirection (append) % command >>& filename Noclobber Variable % set noclobber Setting the noclobber variable protects files from being accidentally overwritten due to output redirection (but not cp, mv, etc.). “!” following any redirection operator over- rides noclobber. Piping Operator % command1 | command2 Enable Tracking of Commands % set history=n Displaying Com- mand History % history Re-executing Previ- ous Commands !! previous command !n nth command !string last command beginning with string !-n nth most recent command !?string? last command containing string Saving Command History % set savehist=n Setting Aliases % alias alias-string command-string Displaying Aliases % alias Deleting Aliases % unalias alias-string Special Files Job Control .cshrc This file, if it exists in your home directory, is automatically executed at login. Must begin with “#” to indicate C shell script. .cshrc typically includes C shell specific commands such as the set noclobber, set history, set savehist, and alias commands. .login This file, if it exists in your home directory, is automatically executed at login. Must begin with “#” to indicate C shell script. .login typically contains generic UNIX commands such as the stty, set path, and umask commands. .logout This file, if it exists in your home directory, is automatically executed at logout. Must begin with “#” to indicate C shell script. .logout typically contains commands to perform cleanup. Running Jobs in the Background % command & Stopping Foreground Jobs % command . . . <CTRL-Z> % Job Status % jobs Killing Jobs % kill %job-number % kill process-id Bringing Jobs to the Foreground % fg %job-number Moving Jobs to the Background % bg %job-number Process Status % ps lists all your processes % ps -a lists all running processes % ps -x full listing for given option Displaying Users % who % whoami