Linux (Unix) Commands
Total Page:16
File Type:pdf, Size:1020Kb
More Linux (Unix) Commands cat - concatenate cat [options] [files] more - display the named files on a terminal, one screenful at a time more [options] [files]Display the named files on a terminal, one screenful at a time. clear – clear screen wc – print byte, word, and line count for each file wc [options] [files] o –c bytes o –l lines o –w words diff – find the difference between two files fileName1 fileName2 grep – search one or more files for lines that match a regular expression pattern grep [options] pattern files o –i ignore case ps – report on active processes ps [options] o –ef select all processes, full listing date – display current date and time date [options] echo – display a line of text echo [string] whoami – displays your user name
File I/O (input/output)
To ‘pipe’ the output of command1 to the input of command2 use the | character (piping information from one process (output) to another (input) o grep -i hp ~info/machines | wc -l o grep -i dell ~info/machines | wc -l o ps -ef | more Redirect the output of a command to another new file o Use the > character to redirect the output of a command to a new file o cat public_html/index.html > newfile Appending to a file o Use the >> to append the output of a command to an existing file o cat public_html/index.html >> newfile Short cuts arrow keys tab
Shell scripts a series of commands in a file that can be executed by a shell command line interpreter To create a shell script o gedit script1 & . Type commands you want to execute date echo “my system has this many active processes” ps –ef | wc –l . Save file o Ensure script1 file has execute permission bits set . i.e. chmod 755 script1 o Execute shell script . script1