Notes: Linux Fundamentals Part 2 | THM
- solbergtonje
- 26 dec. 2024
- 2 min läsning
Remotely Execute Commands
Protocol: Secure Shell (SSH)
- connect/interact w/command line of remote Linux
- encrypted - using cryptography (encrypted - sent - unencrypted)
SSH Syntax
Needed
- IP Address to remote machine
- Credentials to a valid account on remote machine
Command
ssh 'username'@'IP Address'
Asked to trust the host: yes
Provide password for the user (pw won't be visible while typing)
Introduction to Flags and Switches
Most commands allow for arguments (have --help option which list all arguments, ex: ls --help (=man page)), identified by hyphen and certain keyword known as flags or switches
Flags and switches used to extend behaviour of commands
Argument '-a' used with command 'ls' will also list the hidden files: ls -a
The Man(ual) Page
- source of info for system commands and applications
- command: man COMMAND (ex: man ls)
Filesystem Interaction cont.
Commands
touch: create file
mkdir: create folder
cp: copy file/folder
mv: move file/folder
rm: remove file/folder
file: determine type of file
Creating Files and Folders
Create file: touch NAME_OF_FILE
Create folder: mkdir NAME_OF_FOLDER
Removing Files and Folders
Remove file: rm NAME_OF_FILE
Remove folder/directory: rm -R NAME_OF_FOLDER
Copying and Moving Files and Folders
Copy file/folder: cp NAME_OF_EXISTING_FILE NAME_OF_NEW_FILE
Move file/folder: mv LOCATION/NAME_OF_EXISTING_FILE LOCATION/NAME_OF_NEW_FILE (can also be used to rename file)
Determine File Type
Command: file NAME_OF_FILE
Permissions
Some users cannot access certain files/folders
List permissions of all files in current directory
Command: ls -lh
Output:
-rw-r--r-- 1 cmnatic cmnatic 0 Feb 19 10:37 file1
-rw-r--r-- 8 cmnatic cmnatic 0 Feb 19 10:37 file2
r: read
w: write
e: execute
Command to switch user
su USERNAME
(pw)
Start shell with more properties of the other user
su -l USERNAME
(pw)
(= drops into this user's home directory)
Difference between Users & Groups
Use root user permissions with 'sudo'
Common Directories
/etc
- root directory
- important
- store system files used by os
- sudoers: list of users/groups permission to run sudo or set of commands as root user
- passwd & shadow: how system store pw's for each user encrypted sha512
/var
- main root folder
- store data frequently accessed or written by services/applications
- containt log files (/var/log)
/root
- home directory for root system user
- /home/root
/tmp
- unique root directory
- volatile
- store data needed to be accessed once or twice (like memory on computer)
- content cleared out at restart
- any user can write to this folder by default (good place to store things during pentesting, like enumeration scripts)
(egne notater: sikkerhetstiltak: endre default!!)




