Linux commands
echo
whoami
man ls
ls -h
cd
cat
pwd
touch
mkdir
cp
mv
rm
cp note note2
mv note note2
find -name passwords.txt
find -name fileName.py
find -name *.txt
find -FileName *.txt
wordcount:
wc -l <file>
grep (search):
grep "THM" <file>
determine the file type:
file <fileName>
nano myfile
inside nano Ctrl == ^
-
& allows running commands in background of terminal
-
&& combines commands
-
>
redirector, output command -
>>
same output command, appending data -
echo passwords >> password123
-
echo passwords123 >> tryhackme
secure shell (SSH) connect to a remote linux machine. your linux machine + attackbox
- IP address of remote machine
- credentials for login
- ls -lh
- su user2
- user2
/etc stores system files used by linux
/var variable data, accessed by services or apps
/root home for root system user
/tmp temporary directory, any user can write to this folder
wget:
wget https://assets.tryhackme.com/additional/linux-fundamentals/part3/myfile.txt
TRANSFER FILES FROM HOST:
- secure copy
SCP
- copy files & directories your system to remote system
- copy files & directories from remote system to your system
IP address
-
remote system
-
name of file on local system (notes1.txt)
-
name for file on remote system (transferred.txt)
-
scp important.txt ubuntu@x.x.x.x.30:/home/ubuntu/transferred.txt
-
scp ubuntu@x.x.x.x.30:/home/ubuntu/documents.txt notes.txt
SERVING FILES FROM HOST:
python3 -m http.server
wget http://127.0.0.1:8000/file
programs running on the machine managed by the kernel each process has an ID (PID)
- view processes
ps
- see all processes
ps aux
- process stats
top
Managing processes:
- kill a command
kill PID_NUM
kill 1332 SIGTERM
kill process AND cleanupSIGKILL
kill process no cleanupSIGSTOP
stop/suspend process
PID 0 = system init system boot 👢 systemd
then child processes controlled by systemd
but diff process
- web servers, database server or FTP servers start on boot
manually start Apache server then system launch apache2 on boot:
systemctl [option] [service]
- systemctl start apache2
- systemctl stop apache2
- systemctl enable apache2
- systemctl disable apache2
-
background state process
-
foreground state process
echo
,echo &
=> returns PID -
Ctrl + Z background a process
-
ps aux | less
-
thm{processes}
cron
processcrontabs
file
MIN what minute to execute
HOUR what hour to execute
DOM day of month
MON what month of year
CMD the command to be executed
backup file every 12 hours:
0 *12 * * * cp -R /home/../Documents /var/backups/
- https://crontab-generator.org/
crontab -e
to edit
software submissions as 'apt' repository /etc/apt/
add-apt-repository
Task: add the text editor Sublime Text to our Ubuntu machine
- integrity by GPG Gnu Privacy Guard keys for safety of software
- Let's download the GPG key and use apt-key to trust it:
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
- now add Sublime Text 3's repository to our apt sources list.
- create a file named sublime-text.list in /etc/apt/sources.list.d and enter the repository information.
touch sublime-text.list
/etc/apt/sources.list.d
open and paste indeb https://download.sublimetext.com/ apt/stable
apt update
apt install sublime
cd /var/logs
rotating process of auto managing logs
- access log
- error log