General Command Line Flashcards
(148 cards)
General Command Line
create an environment variable for your current session
$ SOMETHING=”something else”
General Command Line
make more permanent changes to your environment
by editing environment files
ex
.bash_profile
.profile
.bashrc
General Command Line
environment variable that determines where the shell looks for executables
$PATH
General Command Line
environment variable that determines the appearance of your prompt
$PS1
ex
$ PS1=’some custom prompt’
\u username
\w working dir
\W basename of working dir
\d current date
\n new line
\h hostname
General Command Line
change the permissions of a file or folder
chmod
ex
$ chmod 740 sample.txt
4 - Read
2 - Write
1 - Execute
General Command Line
jump to the beginning of the prompt
$ Ctrl-a
General Command Line
jump to the end of the prompt
$ Ctrl-e
General Command Line
clear the prompt
$ Ctrl-u
General Command Line
use the mouse to move the cursor in the command line
Option + click
General Command Line
redirect the output from a command to a file
write over >
append >>
ex
$ echo ‘something’ > file.txt
$ echo ‘something else’ >> file.txt
General Command Line
list all the txt files in the parent directory
$ ls ../*.txt
General Command Line
repeat the last command
execute the last command
$ !!
execute the last curl command
$ !curl
General Command Line
search through your recent commands
$ Ctrl-r
General Command Line
redirect the output of one command to the input of another command
|
ex
$ head text.txt | wc
General Command Line
view the last 10 lines of a file that’s constantly changing (like a log file)
$ tail -f file-name
General Command Line
search less
output
/
General Command Line
next match in less
search
n
General Command Line
previous match in less
search
N
General Command Line
beginning of less
output
1G
General Command Line
end of less
output
G
General Command Line
find text within files
grep
ex
$ grep ‘needle’ haystack.txt
General Command Line
make grep
case insensitive
-i
ex
$ grep -i ‘needle’ haystack.txt
General Command Line
print a list of all processes currently running
$ ps aux
General Command Line
terminate a specific process
kill
ex kill -15 pid