quick solaris guide
TRANSCRIPT
-
8/14/2019 Quick Solaris Guide
1/8
-
8/14/2019 Quick Solaris Guide
2/8
Basic Solaris CommandsQuick Reference CardConventions
RETURN key ESCAPE key
DELETE key press key and type xitalics items to be replaced by your ownrequirementsShell Commands
passwd Change passwordlogout End terminal session
File Hierarchycd dir1 Change to directory dir1ls List files in directory
ls -l List files in detailmkdir dir1 Create new directory dir1rmdir dir1 Remove directory dir1c p f1 f2 Copy file f1 to f2mv f1 [f2] dir1 Move files f1 to fn to directorydir1mv dir1 dir2 Rename directory dir1 as dir2rm filename Delete (remove) file filenameln file1 name Create a hard link to file1 callednameln -s file1 name Create a soft link to file1 called
name pwd Show path to current directory
Getting Helpman name Show man page for commandnameman -k subject Show man pages relating to
subject man -s # subject Show man page relating to
subjec t in section number # man -s # Intro Show introductory
File types and Listingfile filename Classify the filestrings filename Show any ASCII strings in a filecat filename Display contents of file to STDOUTmore filename Display contents of file onescreenful at a timehead filename Display first 10 lines of file
-
8/14/2019 Quick Solaris Guide
3/8
head - n filename Display first n lines of filetail filename Display last 10 lines of filetail -n filename Display last n lines of filetail -f filename Recursively display last 10 lines of file
cut Extract character or fields fromtextwc filename Count lines, words and charactersin filediff f1 f2 Find differences between two filesdiff3 f1 f2 f3 Find differences between 3 filessort filename Sort file alphabetically by firstletter uniq Report or filter out repeated lines
Redirection
STDIN Standard Input, typically thekeyboardSTDOUT Standard Output, typically thescreenSTDERR Standard Error, where errors aresent. Typically the screencomm > file Output of comm creates filecomm < file Contents of file used as input tocommcomm 2> filename Error messages from comm sent tofilecomm >> filename Output from comm appended tofilecat file
-
8/14/2019 Quick Solaris Guide
4/8
Symbolic modesMode Meaning Mode Meaningu user r readg group w writeo other x execute
a all u+s setuid= assign g+s setgid+ add +t sticky bit- removeOctal modesBase directory mode is 777. Base file mode is 666user group other r w x r w x r w x4 2 1 4 2 1 4 2 17 7 7Shell Wildcards
Metacharacter Meaning* Any character ? Any single character [ ] A range of characters
Translations and Searchingtr set1 set2 Translates set1 to set2sed Powerful text manipulation toolgrep pattern filenameFinds lines containing pattern infilegrep -v pattern filenameFinds lines NOT containing
pattern in filegrep -i pattern filenameFinds all lines containing
pattern in file ignoring casefind path conditionFinds files matching conditionfrom path downwardsfind path -inum n Finds hard links, i.e. All files withthe same i-node number who Displays users on systemwho am i Shows real user idw Displays users on systemid Shows effective username & UID,and group membershiplook word Searches /usr/dict/words for word
-
8/14/2019 Quick Solaris Guide
5/8
Regular Expressions. Any character ^ Start of line$ End of line* Any number of the preceding characters
? A single character [ ] Holds a range[^ ] Holds a negated range\( \) Creates a submatch\1-9 Reference a submatch
Networkingtelnet hostname [port]Connects to host and opens ashell. Optionally on specified port.
ftp hostname Connects to a remote host totransfer files
ssh hostname [command ]Makes a secure connection tohost and opens a shell.Processes and Process Control
ps Displays processes running on ahost
prstat Displays iterating list of processes by CPU usagecommand & Run command in background
jobs Print list of jobs
fg [%n] Resume foreground job n
bg [%n] Resume background job n
stop %n Suspend background job n
kill [%n] Kill job n
Interrupt process
Suspend current process
kill n Kill process n
-
8/14/2019 Quick Solaris Guide
6/8
kill -9 n Terminate process n
Stop screen scrolling
Resume screen output
sleep n Sleep for n seconds
Shells and Variables
variable=value Create local variable variable
with value value
export variable Make variable an
environmental variableunset variable Remove environment variable
set Show local variables
env Show environmental variables
alias name1 name2 Create command alias
alias Show command aliases
unalias name1 Remove command alias name1
history Display recent commands
! n Submit recent command n
set -o vi Recall commands, edit and reexecute
using vi commands
\ Escapes special character meanings
set -o emacs Recall commands, edit and re-executeusing emacs commands
Shell Initialization
-
8/14/2019 Quick Solaris Guide
7/8
/etc/profile ($HOME/.profile)sh, bash, ksh system wide (per user) init(system wide init has no effect in CDE environment)./etc/.login ($HOME/.login)csh, tcsh system wide (per user) init
(system wide init has no effect in CDE environment).$HOME/.cshrc per user csh, tcsh init(order: /etc/.login $HOME/. cshrc $HOME/.login)$HOME/.kshrc
per user ksh init(order: /etc/profile $HOME/.profile $HOME/.kshrc)$HOME/.bashrc
per user bash init(order: /etc/profile $HOME/.profile $HOME/.bashrc)
Shell Programming
#!path/to/shell 'sh-bang' is a special string whichindicates that the path followingcontains the location of the commandto run the scriptFlow Controlsh;bash;ksh csh;tcshifthenelseif [ condition ];thenactions_1;elif [ condition ];thenactions_2;elseactions_3;fiif (condition)thenaction_1;else if (condition)thenaction_2;elseaction_3;endif dowhilewhile [ condition ];
-
8/14/2019 Quick Solaris Guide
8/8
doactions;donewhile (condition)actions
enduntil until [ condition ];doactions;done
Not availablefor for arg in list ;doactions;doneforeach arg (list)
actionsend
A book by Mohammed Rafique