Bash Shell
The main non-graphical tool to interact with the operating system is Shell.
In FreeBSD there is no GUI at all.
Other notable shells:
ksh
,zsh
,dash
.
Bash Environment
Upon the start of the shell, the OS checks for the existence of several files as:
~/.bashrc
,~/.bash_login
,~/.bash_profile
,~/.bash_logout
.Environment Variables can be viewed by typing
env
.PATH
is a relevant environment variable, which has a format of[location]:[location]:...:[location]
.The
PATH
variable is one of the execution helpers.
Bash Commands and Programs
Bash has some built-in commands that provide basic functionality.
Examples are:
fg
,echo
,set
,while
.Most commands that are used in everyday tasks are external mini-programs kept in
PATH
locations (usewhich
to find the real location).man
displays help about commands.
Bash Output Redirectors and Special Characters
~
: current user's home directory.*
: wildcard that can be used for choosing only certain types of files.$()
: will be evaluated before the whole statement and will become part of this statement.Use
command > file.txt
format to create a file containing command's output.Use
command >> file.txt
format to append containing command's output to an existing file.|
: pipe.chaining commands is a quite powerful Bash feature, one-liners.
Bash Conditional Statements and Loops
chmod +x scriptname
so you can execute this script with./scriptname
Conditional statements:
-eq
: equal-ne
: not equal-lt
: less than-le
: less than or equal-gt
: greater than-ge
: greater than or equal
Loops:
or:
While loop:
for example:
Filters open ports from nmap output files
Fingerprint potential applications:
alivecheck.sh:
Last updated