Docsity

UNIX COMMANDS, Schemes and Mind Maps of Linux skills

Toggle sidebar
bg1
UNIX COMMANDS:
Commands
Description
<
Direct input from a file to a command
e.g.
wc < input.txt
>
Direct output from a command to a file
e.g.
ls > output.txt
>>
Append output from a command to a file
e.g.
date >> output.txt
|
Redirect (pipe) the standard output of one command to the standard input
of another
e.g.
echo hello world | tr โ€œa-zโ€ โ€œA-Zโ€
- sends the output of the echo command to the tr command for translation
to uppercase
;
Combine commands
e.g.
echo hello world ; cal
\
Escape the following special character
e.g.
echo Prompt\>
- prints out Prompt>
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download UNIX COMMANDS and more Schemes and Mind Maps Linux skills in PDF only on Docsity!

UNIX COMMANDS:

Commands Description < (^) Direct input from a file to a command e.g. wc < input.txt

(^) Direct output from a command to a file e.g. ls > output.txt

(^) Append output from a command to a file e.g. date >> output.txt | (^) Redirect (pipe) the standard output of one command to the standard input of another e.g. echo hello world | tr โ€œa-zโ€ โ€œA-Zโ€

  • sends the output of the echo command to the tr command for translation to uppercase ; (^) Combine commands e.g. echo hello world ; cal \ (^) Escape the following special character e.g. echo Prompt>
  • prints out Prompt>

./ (^) Execute a script in the current directory e.g. ./myscript.sh .. Parent directory e.g. cd ..

  • change to parent directory ~ (^) Alias for the home directory e.g. cd ~
  • change to home directory & (^) Run command line in the background ^C (^) (Ctrl + C) kills a running process ^Z (^) (Ctrl + Z) suspend a running process bunzip2 Uncompress a file from zip format e.g. bunzip2 input.txt.bz bzip2 (^) Compress a file to zip format e.g. bzip2 input.txt cat (^) Display the text content of one or more files in consecutive order as one document (can be used to combine files) e.g. cat input1.txt input2.txt
  • changes the permission of input.txt to full access for all users. clear (^) Remove previous output from the shell display comm (^) Compare text files, line by line e.g. comm file1 file cp (^) copy one or more files to another location cut Get text from a file by column or delimited field Options: Options Description
  • f To specify a field number
  • d To specify a field delimiter
  • c To specify a character position e.g. cat test.txt A1,A2,A3,A B1,B2,B3,B C1,C2,C3,C D1,D2,D3,D E1,E2,E3,E F1,F2,F3,F
  • shows the content of test.txt cut - f 2 - d "," test.txt A B C D E F
  • cuts the second field of test.txt separated by a comma df (^) Display file system free space
  • m option to list sizes in Mb, rather than kb.

e.g. df โ€“ m diff Compare two files, line by line and show the differences e.g. diff file1 file diff3 (^) Compare three files, line by line and show the differences e.g. diff3 file1 file2 file du (^) Display disk usage of directories or files

  • h option to display human readable units e.g. du โ€“ h input.txt 4.0K input.txt echo (^) Display input on standard output e.g. echo hello world hello world exit (^) Quit the shell or logout find (^) Find a file in a specified hierarchy e.g. find ~ - name โ€œinput.txtโ€ finger (^) Display personal user information free (^) Display free disk space in Mb units ftp Interactive file transfer via File Transfer Protocol

less (^) Display content, page by page Use Page Down and Page Up keys to move Hit the Q key to return to a prompt e.g. less longfile.txt ls (^) List the contents of the current directory Options: Options Description

  • a To include hidden files
  • l To include access permissions
  • t To order the list by time stamps e.g. ls ls โ€“ lt man (^) Show help page for a command Hit the Q key to return to a prompt e.g. man cat mkdir (^) Make a new directory more (^) Display content, one screen at a time mv (^) More or rename a file or directory passwd (^) Change a password paste (^) Merge files as columns on standard output (can be used to combined files) e.g. paste file1 file rm Remove files or recursively delete directories
  • i option to ask before deleting each file
  • r option to delete a directory and its contents

rmdir (^) Remove an empty directory โ€“ use the rm command to delete non-empty directories scp (^) Securely copy files between two machines โ€“ encrypting transmission and requesting passwords where required sort (^) Display lines of text sorted alphabetically ssh (^) Secure shell login to a remote machine where you already have an account tail (^) Output the last ten lines of a file

  • n option to specify a different number of lines e.g. tail โ€“ n 5 test.txt
  • outputs the last 5 lines in the file test.txt tar (^) Create, update, or extract from a compressed tape archive file Options: Options Description
  • c To create a new archive
  • z To gzip or gunzip
  • u To update an existing archive
  • x To extract files from an archive
  • v To see verbose descriptive output
  • f To use the archive file e.g. tar โ€“ czvf archive.tar.gz Folder/
  • creates and compresses all the contents in Folder as archive.tar.gz e.g. tar โ€“ uzvf archive.tar.gz newfile.txt
  • updates the compressed archive.tar.gz with newfile.txt

Which (^) Display the source file location of a program whoami (^) Display the number of the current effective user zip (^) Create a compressed archive in zip format

  • (^) Any string of characters e.g. ls *.txt
  • lists any file ending with .txt ? (^) Any one character e.g. ls file?
  • lists any file/directory with file and one character at the end [] Match any character in the brackets (a hyphen is used for ranges of characters) e.g. ls file[1-3]
  • lists file1, file2, and file