The Unix shell provides a user interface. “The most basic UNIX shell provides a 'command line' which allows you to type in commands which are translated by the shell into kernel speak and sent off to the kernel.”
$ cat /etc/shells
sh: Bourne shell
csh: C-shell
tcsh: C-shell enhanced with file name completion and command line editing.
ksh: Korn shell
bash: Bourne again shell
zsh: Z shell (oh my zsh)
BASH "Bourne Again SHell" It was a replament for the Bourne Shell. Shell scripting is scripting in any shell. BASH scripting is scripting for BASH.
When you launch a terminal you get a terminal emulator window with bash running inside of it, generally by default.
Default shell for most linux, MacOS, WSL and solaris https://en.wikipedia.org/wiki/Bash_(Unix_shell)
Who am I
whoami
Which groups am I in
groups
Is dotnet installed and version (hopefully 2.1)
dotnet --info
List files and directorys
ls
ls -l #long format, include permissions
ls -a #include hidden files
ls -la
ls -la .ssh
See your public key
cat .ssh/authorized_keys
Create a directory
mkdir newdir
mkdir newdir1 newdir2 newdir3
mkdir -p newdir/sonof/grandsonof
mkdir -m 777 foo
Remove files and directories
rm file.txt
rmdir directory
rm -r directory
Create a file
touch filename
Show contents of file
cat file.txt
Show running process
top
top -u user #user processes
- q - quit
- k - kill
- c - absolute path of process
- shift+p - sort by cpu
List of processes
ps
ps -A
Manual pages
$ man grep
Zipping files
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
- -c: Create an archive.
- -z: Compress the archive with gzip.
- -v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
- -f: Allows you to specify the filename of the archive.
- -C: Change directory before hand
Create a user
useradd [options] {username}
useradd user
useradd -m -d /home/user -s /bin/bash user
Find the username
cat /etc/passwd | grep user