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

Similar to csh_cheatsheet.pdf

Unix commands
Unix commandsUnix commands
Unix commands
Divya_Gupta19
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent card
Bui Van Cuong
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
Bootcamp linux commands
Bootcamp linux commandsBootcamp linux commands
Bootcamp linux commands
NexThoughts Technologies
 
List command linux a z
List command linux a zList command linux a z
List command linux a z
Jinyuan Loh
 
Terminal linux commands_ Fedora based
Terminal  linux commands_ Fedora basedTerminal  linux commands_ Fedora based
Terminal linux commands_ Fedora based
Navin Thapa
 
List command linux fidora
List command linux fidoraList command linux fidora
List command linux fidora
Jinyuan Loh
 
apache-refcard-a4.pdf
apache-refcard-a4.pdfapache-refcard-a4.pdf
apache-refcard-a4.pdf
GiovaRossi
 
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
Ranjan Raja
 
Commands
CommandsCommands
Commands
damlepramod
 
archive A-Z linux
archive A-Z linuxarchive A-Z linux
archive A-Z linux
elahe salimi
 
Comenzi unix
Comenzi unixComenzi unix
Comenzi unix
Valentin Valentin
 
Group13
Group13Group13
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commands
Ben Pope
 
Bash cheat sheet
Bash cheat sheetBash cheat sheet
Bash cheat sheet
MRATUNJAI TIWARI
 
Bash cheat sheet
Bash cheat sheetBash cheat sheet
Bash cheat sheet
Jogesh Rao
 
Linux
LinuxLinux
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
Ahmed El-Arabawy
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
Kuntal Bhowmick
 

Similar to csh_cheatsheet.pdf (20)

Unix commands
Unix commandsUnix commands
Unix commands
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent card
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Bootcamp linux commands
Bootcamp linux commandsBootcamp linux commands
Bootcamp linux commands
 
List command linux a z
List command linux a zList command linux a z
List command linux a z
 
Terminal linux commands_ Fedora based
Terminal  linux commands_ Fedora basedTerminal  linux commands_ Fedora based
Terminal linux commands_ Fedora based
 
List command linux fidora
List command linux fidoraList command linux fidora
List command linux fidora
 
apache-refcard-a4.pdf
apache-refcard-a4.pdfapache-refcard-a4.pdf
apache-refcard-a4.pdf
 
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
 
Commands
CommandsCommands
Commands
 
archive A-Z linux
archive A-Z linuxarchive A-Z linux
archive A-Z linux
 
Comenzi unix
Comenzi unixComenzi unix
Comenzi unix
 
Group13
Group13Group13
Group13
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commands
 
Bash cheat sheet
Bash cheat sheetBash cheat sheet
Bash cheat sheet
 
Bash cheat sheet
Bash cheat sheetBash cheat sheet
Bash cheat sheet
 
Linux
LinuxLinux
Linux
 
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 shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
 

Recently uploaded

HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
Donato Onofri
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
Tarandeep Singh
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
k4ncd0z
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
3a0sd7z3
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
rtunex8r
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
xjq03c34
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
APNIC
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
APNIC
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
3a0sd7z3
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
thezot
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
davidjhones387
 

Recently uploaded (12)

HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
 

csh_cheatsheet.pdf

  • 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