[last updated: 2021-02-10]
Linux Commands
-----
- Linux commands are case-sensitive.
- Every character matters - spaces included.
- Commands shown here may start with a '$'. This is short-hand for your command line prompt, and should not be typed in as a character.
- Filenames and directory names may NOT Contain spaces.
- Some commands require root account permissions:
If you are not logged in as a root user, you must preface your command with "sudo "
If you want to log in as a root user, type: $ sudo su [though it is not recommended]
The '$' which is the last character in your prompt, will change to a '#'.
To return to standard (non-root) user status, type: # exit
- The words 'folder' and 'directory' are used as equivalent/synonymous.
----------------------------------------------------------------------------------------------
- Executing Linux commands:
----------------------------------------------------------------------------------------------
- General Programming Notes:
- If you use a variable in a command, intending to reference its value,
you must precede the variable name with a ' $ '
$ str01="tmp" ... no $ needed, defining str01, not referencing its value
$ echo $str01 ... $ needed, intending to echo the value of str01 to output
- Re-direct the output of a command:
$ ls > tmp.txt ... sends the output of "$ ls" to create a file named tmp.txt.
If the file already exists, it will overwrite whatever's there with this new output.
- If tmp.txt already exists, and you want to preserve its content and just add to it,
then append this new output to the end of it with:
$ ls >> tmp.txt
- Re-direct the input to a command:
$ sort < tmp.txt
content of tmp.txt will be sent to sort, then the sorted output will be sent to screen.
- Re-direct both input and output
$ sort < tmp.txt > tmp1.txt
sorted output sent to new file
- Pipes:
$ ls | less ... shows lts output a page at a time allowing scrolling
$ ls | more ... shows its output a page at a time, but no scrolling allowed, must press enter to get next page
$ ls | grep "file" ... sends ls output through grep filter, and only displays items containing "file"
[Clearly this only describes a tiny fraction of a very complex and rich feature...]
-
----------------------------------------------------------------------------------------------
.
.
.
eof