touch
: create filels
: list of filescd
: change directory home dir:~
parent dir:..
current dir:.
pwd
: display current directorymkdir
: make directoryls -a
: view list of files with hidden filescat
: read filesgrep (searchstring) (directory)
: to find text within a filefind (path) -name (filename)
: to find files within directoriesln -s (original file loc) (new loc)
: for symlinking files a hardlink is a link which refers to two different names for a specific physical place a softlink is like creating a new fwding address for the previously located physical placeman
: to read manual page for a command to search in a manual page use/
man man
to get man command's man pageman -k (text)
to search for a command within a man page(command) --help
: to know how to details about a command you can run help for builtins usinghelp (command)
echo
: outputs str as passed to it
?
for one char*
for multiple char, wildcard[abc]
for limited chars within brackets[^abc]
for all chars except those in brackets
-
redirecting output from file desrciptor to file:
>
-
redirecting output in append mode
>>
-
redirect stdout
1>
same as>
-
redirecting stderr
2>
-
redirecting input
<
-
to avoid storing a file, you can pipe the output using
|
-
you can redirect from file descriptor to file descriptor using
>&
-
you can use
| tee (1) (2)
to save the middleman output of what is happening in halfway stage of running your command by saving it to a file or saving an error/result midway
echo $VAR
to read variablesVAR=value
to set value- multi word vars, use
""
export VAR=value
to save value of variable so future shell programs inherit the valueenv
: to print every exported var- to save output of command into var:
VAR=$(program)
read
to read files directly instead of using cat
ps
orps aux
to list all running processeskill
to kill processes- ctrl+c to interrupt process
- suspend into bg ctrl+z
- fg to foreground a process
- bg to resume in background
- to start processes backgrounded from the start use
sleep processid &
- echo
$?
to read exit code of process
su (user)
then enter pass to login, use tool johntherippersudo
to exec as root- semicolon to chain commands
- export
PATH=xyz:$PATH
to append to path
chown (user) (filedir)
to change ownershipchgrp
for changing groupsid
to identify which users groups have permissions to use the filechmod (u or g or o) (+ or -) (r or w or x) (filedir)
chmod u=rx,g=rx (filedir)
using commas and = can also be donechmod u+s (programdir)
to add it to SUID bit