- **useradd -m **username
- -m creates a home directory for the user
- passwd username
- **usermod -a -G sudo **username
- to add user to group, e.g. sudo
- **chsh -s /bin/bash **username
- specify shell for a user?
**apt-get install **pkg
- **uname -a **- kernel info
- ifconfig/ ip addr show - network informationq
- **netstat/ lsof -i - **info about ports/routing
- **df **- (disk free )display disk space
- **systemctl - **info about running services
- du - disk usage
- **top/htop/ps - **display CPU usage/precesses
- **ls /mnt - **list mounted devices
- **mount - **show existing mounts
- e.g **mount /dev/sda2 /mnt - **mount sda2 device to /mnt
- **less /etc/fstab - **boot device list
4 command types:
- ** An executable command**
- A command built in into the shell
- A shell function
- An Alias
- **type **command - display cmd type
- which cmd - display executable location
- **help **cmd
** rm -r **- remove directory and its content
**info/man coreutils - **dispaly info (manual) about cmd
Installing something:
- sudo apt install program
- **cat - **
- **sort - **
- **uniq - **
- **grep - **
- **wc - **
- **head - **
- **tail - **
- tee -
- **ls -l /usr/bin > ls-output.txt - **send output results to a file
- **ls -l /usr/bin >> ls-output.txt - **append redirection to the same file (no owerwrite)
- **ls -l /bin/usr 2> ls-error.txt - **redirect error to a file
- **ls -l /bin/usr &> ls-output.txt **redirect output and error to the same file
- 0 - input
- 1 - output
- 2 - error
- /dev/null - location to discard putput etc.
- ls -l /bin/usr 2> /dev/nullls
**Pipelines **used to filter commands
- ls -l /usr/bin | less
- **ls -l /bin /usr/bin | sort | less - **output of two directories sorted in one list
- ls /bin /usr/bin | sort | uniq | less - removes any dublicates
- **ls /bin /user/bin |sort | uniq -d | less - ** show list of dublicates
wc: - Print word, line, byte counts
grep: Print lines matching pattern
- **grep **pattern filename
- ls /bin /usr/bin | sort | uniq | grep zip_ - _programs that have zip in the name
head/tail - print first/last 10 lines
tail -f - usefull for watching the progress of log files