Linux

Linux
 Basics

Basics

Commands

  • echo [OPTION]... <YourText> -> prints out what comes after it

  • whoami [OPTION]... -> prints out ur username

  • ls [OPTION]... [FILE]... -> listing

  • cd <PathToDirectory> -> change directory

  • cat [OPTION]... <Filename> -> concatenate (list what is written in a file)

  • pwd -> print working directory

  • Ctr + L or clear -> clear terminal

  • find [OPTION]... [FILE]... -> to find

  • wc [OPTION]... [FILE]... -> prints how many newline (new entries), word, and byte counts are in [FILE]...

  • grep [OPTION]... <PATTERNS> [FILE...] -> to find any entries in [FILE...]

  • ssh [OPTION]... <username>@<IP-address> [command]... -> to connect with another computer via ssh

  • man [OPTION]... <PROGRAMM> -> to get a manual for the use of the specified programm

  • su [OPTION]... [username] -> “switch” between users

  • wget [OPTION]... <URL>... -> allows us to download files from the web

  • scp <Source> <username>@<IP-address>:<DESTINATION> -> [Secure copy] Copy files & directories from your current system to a remote system via SSH

  • scp <username>@<IP-address>:<Source> <DESTINATION> -> [Secure copy] Copy files & directories from a remote system to your current system via SSH

  • python3 -m http.server [OPTION]... -> turns your computer into a quick and easy web server

Filesystem Interaction (Continued)

  • touch [OPTION]... <Filename> -> Create file

  • mkdir [OPTION]... <DIRECTORY> -> [make directory] Create a folder

  • cp [OPTION]... <SOURCE>... <DIRECTORY | DEST> -> [copy] Copy a file or folder

  • mv [OPTION]... <SOURCE>... <DIRECTORY | DEST> -> [move] Move a file or folder

  • rm [OPTION]... <Filename>... -> [remove] Remove a file or folder

  • file [OPTION]... <Filename>... -> Determine the type of a file

Processes 101

  • ps [OPTION]... -> provides a list of running processes from our users session

  • ps aux [OPTION]... -> processes run by other users and those that don’t run from a session

  • top [OPTION]... -> real-time statistics about the processes running on your system

  • fg [1][2] <JOB_SPEC> -> bring a background process back into use on the terminal

kill [OPTION] <PID> [...] -> send signals that terminate processes
-<signal>Description
SIGTERMKill the process, but allow it to do some cleanup tasks beforehand
SIGKILLKill the process - doesn’t do any cleanup after the fact
SIGSTOPStop/suspend a process
systemctl [OPTION...] <COMMAND> <SERVICE...> -> interact with systemd:

system and service manager

<COMMAND>Description
startStart/activate one or more services specified
stopStop/deactivate one or more services specified
enableEnable one or more services or service instances [start service on the boot-up]
disableDisables one or more services [stop the start of service on the boot-up]

Shell Operators

Symbol /

Operator

Description
& This operator allows you to run commands in the background of your terminal.
&& This operator allows you to combine multiple commands together in one line of your terminal.
> This operator is a redirector - meaning that we can take the output from a command (such as using cat to output a file) and direct it elsewhere.
>> This operator does the same function of the > operator but appends the output rather than replacing (meaning nothing is overwritten).
  • Ctrl + Z -> to background a process. (effective way of “pausing” the execution of a script or command)

System Automation

crontab -e

-> to edit the crontabs [specialfies]

Online Generators
Crontab GeneratorCron Guru

Formating options for crontab

  • [@reboot] OR [MIN HOUR DOM MON DOW] CMD
    ValueOptionsDescription
    @reboot----------Execute after [re-] booting
    MIN* or [0-59]What minute to execute at
    HOUR* or [0-23]What hour to execute at
    DOM* or [0-31]What day of the month to execute at
    MON* or [1-12] or [JAN-DEC]What month of the year to execute at
    DOW* or [0-6] or [SUN-SAT] or [7]What day of the week to execute at
    CMD<command>...Actual command that will be executed
    • Example:
      @reboot echo "Welcome back!"
    • OR
    • 0 */12 * * * echo "Hi" -> Only executed every 12 hours

Permissions [-rwxrwxrwx]

- rwx rwx rwx
Filetype:  
-dl
filedirectorysymbolic link
read, write and execute

-> permissions for file owner  

read, write and execute

-> permissions for group owner(s) of the file

read, write and execute

-> permissions for all other users

  • ln -s <SourceFile> <LinkName> -> create symbolic soft links

Common Directories (root directories)

Directorie Description
/etc The /etc directory (short for etcetera) is a commonplace location to store system files that are used by your operating system.
/var The /var directory (short for variable data) stores data that is frequently accessed or written by services or applications running on the system
/root The /root directory is actually just the home for the “root” system user.
/temp The /tmp directory (short for “temporary”) is volatile and is used to store data that is only needed to be accessed once or twice. [What’s useful for us in pentesting is that any user can write to this folder by default.]
  • “passwd” and “shadow” files -> (special for Linux, located in the /etc directory) shows how your system stores the passwords for each user in encrypted formatting ( old:sha512 | new:yescrypt ).
  • crack password hash with “John the Ripper[3][4] using the command john --format=crypt <filename>

~ Build with Markdown by femilu_ ~