Linux Commands & Examples

MkCert -

Make Certificate
Man Page
doc1

SYNTAX
mkcert [-]

SWITCH
-
-

EXAMPLE



ALSO SEE:

SUDO -

SuperUser DO
Man Page

SSH -

Secure Shell, OpenSSH remote login client
Man Page
doc1 - Mastering OpenSSH - Linux Journal
doc2 - How to use SSH - geekforgeek

SYNTAX
ssh [-] [username]@[remote_IP]

SWITCH
-p port (change default port 22)
-q quiet mode
-1 Use protocol version 1 only
-2 Use protocol version 2 only
-V Display the version number

EXAMPLE
ssh user@192.168.1.5
ssh -p 2222 username@remote_ip

Nmap -

Network Mapper, network exploration tool and security / port scanner
man page
doc1 - Nmap Cheat Sheet - geeksforgeeks.org

SYNTAX
nmap [Scan Type...] [Options] {target specification}

SWITCH
-p ports
-A perform OS and service detection

EXAMPLE
basic nmap ping sweep
nmap -sP 192.168.2.1-254 | grep -i nmap

Grep -

Print lines that match pattern
man page
doc1 - Unlocking Grep - linuxjournal.com

SYNTAX
grep [OPTION...] PATTERNS [FILE...]

SWITCH
-i case insentive
-A (print the specified N lines after match)

EXAMPLE
Display N lines after match
grep -A 'string' FILENAME

Find -

Search the live filesystem for files and directories using different criteria
man page
doc1 - Find Command - geeksforgeeks.org

SYNTAX
grep [options] starting_point PATTERNS [FILE...] action

SWITCH
-type fstype (Specifies the type of file to search for 'fstype'(e.g., f for regular files, d for directories).)
-delete (Delete all matched files) -maxdepth n (Limits how deep into subdirectories the search goes)
-group name (Matches files that are owned by the 'name' group)
-exec command {} \; (Executes a command on each matched file)

EXAMPLE
find /path/to/search -type f -name "*.txt"
sudo find / -type f -name "ports.conf"
-Delete all matched files
find /tmp -name “*.tmp” -delete
-which makes a copy of each matched file
find /etc -name "*.cfg" -exec cp {} /tmp/{}.bak \;

Useradd -

Create A New User
man page
doc1 - 15 useradd Examples - TechMint.com

SYNTAX
useradd [options] username

SWITCH
-u UID
-g GID
-G group1,group2,group3
-U (Create a group with the same name as the user, and add the user to this group)
-d HOME_DIR
-M (Do not create home dir)
-m (Create the user's home directory if it does not exist)
-s SHELL (/sbin/nologin)
-N (Do not create a group with the same name as the user)
-r (Create a system account)
-c COMMENT

EXAMPLE
useradd -U -m -d /var/vmail -s /sbin/nologin -u 2000 vmail
sudo useradd -M -s /usr/sbin/nologin [username]

ALSO SEE:
usermod, userdel, groups, groupmod, groupadd, groupdel

Usermod -

Modify a user account
man page
doc1 -

SYNTAX
usermod [options] LOGIN

SWITCHES
-aG GROUP (add/append user to GROUP)
-d HOME_DIR (new home dir)
-l NEW_LOGIN (The name of the user will be changed from LOGIN to NEW_LOGIN. Nothing else is changed.) (dont forget to change users home DIR)
-u UID (change a users UID)
-s SHELL (change a users default SHELL)

EXAMPLE
sudo usermod -a -G groupName userName

Chown -

Change owner, change the user and/or group ownership of each given File to a new Owner
man page
usage Doc1

-c Verbosely describe the action for each FILE whose ownership actually changes
-R Recursively change ownership of directories and their contents

EXAMPLE
Assign bob as the owner of "MyFile.txt" file in the Shared directory
$ sudo chown bob /Users/Shared/MyFile.txt
Assign bob as the owner, and staff as the group for everything in the "tmp" folder
$ sudo chown -R bob:staff /Users/Shared/tmp/


Chmod -

change file mode bits (access permissions)
man page
doc1 -

SYNTAX
chmod [OPTION]... MODE[,MODE]... FILE...

SWITCHES
-f, --silent Suppress most error messages
-v, --verbose Output a diagnostic for every file processed
-c, --changes like verbose but report only when a change is made
-R, --recursive Change files and directories recursively

EXAMPLE
chmod 0755 file
chmod 0655 file
chmod 400 file - Read by owner
chmod 040 file - Read by group
chmod 004 file - Read by world
chmod 777 file - Allow everyone to read, write, and execute file

SCP -

Secure copy
man page
doc1 -

EXAMPLE
Copy File from a remote host to local host
$ scp username@from_host:file.txt /local/directory/

Copy File from local host to a remote host
$ scp file.txt username@to_host:/remote/directory/

Copy DIR from a remote host to local host
$ scp -r username@from_host:/remote/directory/ /local/directory/

Copy DIR from local host to a remote host
$ scp -r /local/directory/ username@to_host:/remote/directory/

Copy file from remote host to remote host
$ scp username@from_host:/remote/directory/file.txt username@to_host:/remote/directory/

Bat -

def
Man Page
doc1

SYNTAX
command [-]

SWITCH
-
-

EXAMPLE



ALSO SEE: