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

PPTX
Process monitoring in UNIX shell scripting
PPTX
Cis 216 – shell scripting
PPT
Chap06
PPTX
Unix - Shell Scripts
PDF
Workshop on command line tools - day 2
PDF
Workshop on command line tools - day 1
PPTX
Unix shell scripts
PDF
Bash Scripting Workshop
Process monitoring in UNIX shell scripting
Cis 216 – shell scripting
Chap06
Unix - Shell Scripts
Workshop on command line tools - day 2
Workshop on command line tools - day 1
Unix shell scripts
Bash Scripting Workshop

What's hot (20)

PDF
Introduction to shell scripting
PPT
Linux shell scripting
PPT
Shell Scripting
DOCX
lec4.docx
PDF
Shell scripting
PPTX
Pipes and filters
PDF
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
PPT
Unix Shell Scripting Basics
PPT
Unix And Shell Scripting
PPTX
Creating a keystroke logger in unix shell scripting
PDF
Vim Hacks (OSSF)
PPTX
Shell programming 1.ppt
PPTX
Linux shell env
PPT
Unix Shell Scripting Basics
PDF
Shell实现的windows回收站功能的脚本
PPTX
Unix shell scripting
PDF
Memory Manglement in Raku
ODP
Shellscripting
PDF
Using the Command Line with Magento
PDF
KubeCon EU 2016: Custom Volume Plugins
Introduction to shell scripting
Linux shell scripting
Shell Scripting
lec4.docx
Shell scripting
Pipes and filters
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Unix Shell Scripting Basics
Unix And Shell Scripting
Creating a keystroke logger in unix shell scripting
Vim Hacks (OSSF)
Shell programming 1.ppt
Linux shell env
Unix Shell Scripting Basics
Shell实现的windows回收站功能的脚本
Unix shell scripting
Memory Manglement in Raku
Shellscripting
Using the Command Line with Magento
KubeCon EU 2016: Custom Volume Plugins
Ad

Similar to Unix cheatsheet (20)

PDF
unix_ref_card.pdf
PDF
unix_ref_card.pdf
PDF
unix_ref_card.pdf
PDF
PPS
QSpiders - Unix Operating Systems and Commands
PDF
Unix and Linux - The simple introduction
PPTX
Linux Commands all presentation file .pptx
PPTX
Linux System commands Essentialsand Basics.pptx
PDF
Presentation aix basic
PDF
basic-unix.pdf
PDF
UNIX Command Cheat Sheets
TXT
PPTX
Commands and shell programming (3)
PDF
Linux cheat sheet
PPT
8.1.intro unix
PPT
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
DOCX
Directories description
PDF
Linux cheat sheet
DOC
58518522 study-aix
PPT
Unix tutorial-08
unix_ref_card.pdf
unix_ref_card.pdf
unix_ref_card.pdf
QSpiders - Unix Operating Systems and Commands
Unix and Linux - The simple introduction
Linux Commands all presentation file .pptx
Linux System commands Essentialsand Basics.pptx
Presentation aix basic
basic-unix.pdf
UNIX Command Cheat Sheets
Commands and shell programming (3)
Linux cheat sheet
8.1.intro unix
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
Directories description
Linux cheat sheet
58518522 study-aix
Unix tutorial-08
Ad

Recently uploaded (20)

PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
Principal presentation for NAAC (1).pptx
PDF
Prof. Dr. KAYIHURA A. SILAS MUNYANEZA, PhD..pdf
PDF
Computer System Architecture 3rd Edition-M Morris Mano.pdf
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
MAD Unit - 3 User Interface and Data Management (Diploma IT)
PPTX
Amdahl’s law is explained in the above power point presentations
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
PDF
Computer organization and architecuture Digital Notes....pdf
PDF
Introduction to Power System StabilityPS
PDF
First part_B-Image Processing - 1 of 2).pdf
PPTX
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
PPTX
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
PDF
MLpara ingenieira CIVIL, meca Y AMBIENTAL
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PPTX
Module 8- Technological and Communication Skills.pptx
PPTX
mechattonicsand iotwith sensor and actuator
PDF
20250617 - IR - Global Guide for HR - 51 pages.pdf
PDF
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
Exploratory_Data_Analysis_Fundamentals.pdf
Principal presentation for NAAC (1).pptx
Prof. Dr. KAYIHURA A. SILAS MUNYANEZA, PhD..pdf
Computer System Architecture 3rd Edition-M Morris Mano.pdf
August -2025_Top10 Read_Articles_ijait.pdf
MAD Unit - 3 User Interface and Data Management (Diploma IT)
Amdahl’s law is explained in the above power point presentations
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
Computer organization and architecuture Digital Notes....pdf
Introduction to Power System StabilityPS
First part_B-Image Processing - 1 of 2).pdf
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
MLpara ingenieira CIVIL, meca Y AMBIENTAL
"Array and Linked List in Data Structures with Types, Operations, Implementat...
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
Module 8- Technological and Communication Skills.pptx
mechattonicsand iotwith sensor and actuator
20250617 - IR - Global Guide for HR - 51 pages.pdf
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK

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