SlideShare a Scribd company logo
1 of 2
Download to read offline
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

Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scriptingCorrado Santoro
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filtersbhatvijetha
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...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 BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell ScriptingJaibeer Malik
 
Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingCreating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingDan Morrill
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)Lin Yo-An
 
Shell programming 1.ppt
Shell programming  1.pptShell programming  1.ppt
Shell programming 1.pptKalkey
 
Linux shell env
Linux shell envLinux shell env
Linux shell envRahul Pola
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsDr.Ravi
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Lingfei Kong
 
Using the Command Line with Magento
Using the Command Line with MagentoUsing the Command Line with Magento
Using the Command Line with MagentoMatthew Haworth
 
KubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume PluginsKubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume PluginsKubeAcademy
 

What's hot (20)

Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingCreating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scripting
 
Vim Hacks (OSSF)
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)
 
Shell programming 1.ppt
Shell programming  1.pptShell programming  1.ppt
Shell programming 1.ppt
 
Linux shell env
Linux shell envLinux shell env
Linux shell env
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
Using the Command Line with Magento
Using the Command Line with MagentoUsing the Command Line with Magento
Using the Command Line with Magento
 
KubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume PluginsKubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume Plugins
 

Similar to Unix cheatsheet

Similar to Unix cheatsheet (20)

csh_cheatsheet.pdf
csh_cheatsheet.pdfcsh_cheatsheet.pdf
csh_cheatsheet.pdf
 
apache-refcard-a4.pdf
apache-refcard-a4.pdfapache-refcard-a4.pdf
apache-refcard-a4.pdf
 
Unix cmd
Unix cmdUnix cmd
Unix cmd
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
2005_Structures and functions of Makefile
2005_Structures and functions of Makefile2005_Structures and functions of Makefile
2005_Structures and functions of Makefile
 
Basics of Unix Adminisration
Basics  of Unix AdminisrationBasics  of Unix Adminisration
Basics of Unix Adminisration
 
Quick guide of the most common linux commands
Quick guide of the most common linux commandsQuick guide of the most common linux commands
Quick guide of the most common linux commands
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent card
 
Terminal linux commands_ Fedora based
Terminal  linux commands_ Fedora basedTerminal  linux commands_ Fedora based
Terminal linux commands_ Fedora based
 
Linux
LinuxLinux
Linux
 
List command linux fidora
List command linux fidoraList command linux fidora
List command linux fidora
 
Unix commands
Unix commandsUnix commands
Unix commands
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Lnx
LnxLnx
Lnx
 
Bootcamp linux commands
Bootcamp linux commandsBootcamp linux commands
Bootcamp linux commands
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os lab
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
List command linux a z
List command linux a zList command linux a z
List command linux a z
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11
 

Recently uploaded

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Recently uploaded (20)

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

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