Linux principles:
- everything in Linux is a file
- small a single purpose programs
- chain programs together to perform a complex purpose
- avoid user interface
- configuration in a text file
Terms:
Bash is a sort of Shell, other shells, fx: Fish, Zsh, Ksh
A Terminal, also called a shell, is a GUI to interact with the kernel.
Linux folder
/(forward slash): Root
/home/username: each user has a personal folder
/bin: command binaries.
/etc: local system configuration files
/lib: shared libs shared for system boot
/opt: the third-party tools
/var: variable files, fx: log files
Linux commands
ls -a: list all files including hidden ones.
ls -l: list files in a long format.
ls -l *.txt
cd: change the current directory
.. indicates the parent folder
mkdir: make a new folder
mkdir folder1 folder2: creating several folders
mkdir -p folder/nested-folder: creating m-nested folders
rmdir: remove a folder
rm: remove one file or multiple files
rm blue red yellow
rm -v blue red yellow
-v: verbose. -r: recursive -i: interactive -f: force
rm -rf folder-name
touch: if the file is not existed, create one, else update to a new timestamp.
touch new-file-name
open: open a file or directory just like double-clicked file icon.
open. open the current folder in a graphic presentation
open file-name: open the file in OS default text editor
> : redirect output console
date > newFile.text: output current date to designated file, and overwrite the file entirely.
>>: redirect out the console and appending
date>> newFile.text: out current date to designated file, and appending.
cp: copy file or folder
less: a UI showing the entire file, scrolling down and up.
less file-name
WC: word count
wc -l file-name: shows line number in a file
wc -w file-name: shows how many words are in a file
piping |: taking one command output as input of another command.
Env var
expending dollar sign or tilde
dollar sign path
echo * all path names
echo *.txt
? matching each single character
cry0l1t3@htb[/htb]$ ls -l /etc/passwd
- rwx rw- r-- 1 root root 1641 May 4 23:42 /etc/passwd
- --- --- --- | | | | |__________|
| | | | | | | | |_ Date
| | | | | | | |__________ File Size
| | | | | | |_______________ Group
| | | | | |____________________ User
| | | | |_______________________ Number of hard links
| | | |_ Permission of others (read)
| | |_____ Permissions of the group (read, write)
| |_________ Permissions of the owner (read, write, execute)
|____________ File type (- = File, d = Directory, l = Link, ... )
chmod 777 file-name : change file read-write-executable
find . -name fileName: find the current folder by name
which: shows the path to a file
which file-name: locate a file
ps: shows all processes
ps -ef: extended format
ps -ef | grep bash
kill PID: kill by its process ID
top: show statistics of system usage
wget URI: download resources
su: switch user to log in as someone else
exit: log out a user account
sudo: super user do, run a command as a root user
sudo apt update: update the APT package index in line with the repository.
sudo apt upgrade: update the installed packages to the latest version.
sudo apt upgrade specific-package: update an installed package to the newest version.
sudo apt install package-name: install package
source file-name [argument]: shell built-in command that can execute a file containing a list of shell commands.
export: built-in shell command to mark env variable to export the child processes(change visibilities).
sh xxx.sh: execute a script file
Vi/Vim Editor
Network
Check Remote Ports are Reachable Using ‘nc’ Command
-v – enables verbose mode.
The next command will check if ports 80, 22 and 21 are open on the remote host 192.168.5.10 (we can use the hostname as well):
nc -zv 192.168.56.10 80 22 21
No comments:
Post a Comment