|
ssh user@host
|
|
|
ssh user@host (port)
|
|
man (command) = Shows the manpages for the current command
|
|
(Command) --help = Less detailed version of manpages
|
|
whatis <command> -Gets short one line manual page to describe
|
|
grep "TODO" files = Searches for TODO in files
|
|
grep -r "TODO" dir = Searches recursively for TODO in the directory
|
|
locate (file) = Finds all instances of file
|
|
find (file) = Find all instances of file
|
|
netstat -rn -displays destination network and hosts of routing table
|
|
ifconfig lo 127.0.0.1 . -assigns loopback to 127.0.0.1
|
|
ifconfig eth0 127.17.75.20 . -assigns ethernet device to IP
|
|
route add default gw 128.17.75.98 . -adds route to routing table
|
|
clear (clears command line)
|
|
Make script executable: chmod +x <scriptname>
|
|
|
./<scriptname> - Execute script
|
|
if [ -d "$1" ] (Directory)
|
|
|
elif [ -h "$1" ] (Symbolic Link)
|
|
|
elif [ -f "$1" ] (File)
|
|
history | less
|
|
sudo \cp /usr/share/doc/dhcp-server/dhcpd.conf.example /etc/dhcp/dhcpd.conf (Setup New Empty Config)
|
|
|
Setup Static IP: ip addr add 192.168.114.1 dev br0;
|
|
|
Setting up bridging: sudo dnf install bridge-utils
|
|
|
sudo brctl addbr br0; sudo brctl addif enp1s0; sudo brctl addif eno1; sudo ifconfig br0 up
|
|
sudo useradd <username>
|
|
|
sudo smbpasswd -a <username>
|
|
Create single file: touch example
|
|
|
Create multiple files: touch example1 example2
|
|
|
Set current time and date of file: touch -a example
|
|
|
Create file with specified time: touch -t YYMMDDHHMM.SS example
|
|
command < file (Read input of command from file)
|
|
|
command > file (Write output of command to file)
|
|
|
command > /dev/null (Discard output of command)
|
|
|
command >> file (Append output of file)
|
|
|
command1 | command2 (Pipe output of command1 to command2)
|
|
mkdir (dir) [Creating Directory]
|
|
pwd [Show current directory]
|
|
cp file1 file2 [Copies file1 to file 2]
|
|
cp -r dir1 dir2 [Copies dir1 to dir2]
|
|
rm file/ rm -r dir [Remove file or remove directory]
|
|
chmod ugo=rwx file = Changes permissions of file to Read, write, and execute for the User,Group, and all Others. This command can have many iterations.
|
|
chmod 777 = First digit is read(4+2+1), second is write(4+2+1), and the third is (4+2+1). Many combinations of numbers can be used.
|
|
dig oreilly.com -returns information help by domain
|
|
sudo systemctl start/stop/restart 'nginx.service' . -start, stop, and restart service with systemctl
|
|
sudo systemctl enable/disable 'nginx.service' -disables or enables service
|
|
systemctl list-units --all . -lists all units systemd has loaded into the system
|
|
journalctl . -view all log entries
|
|
sudo systemctl edit 'nginx.service' . -modify service directly
|
|
Exit 0 (Standard exit)
|
|
|
Exit (1,2,3,etc.) - If you want to customize for your script
|
|
/ - Root
|
|
|
/bin – Essential User Binaries
|
|
|
/boot – Static Boot Files
|
|
|
/dev – Device Files
|
|
|
/etc – Configuration Files
|
|
|
/home – Home Folders
|
|
|
/lib – Essential Shared Libraries
|
|
option domain-name “sap.cslab.moravian.edu”;
|
|
|
option domain-name-servers sap.cslab.moravian.edu;
|
|
|
authoritative;
|
|
|
log-facility local7;
|
|
Creating an array: array=("This" "is" "an" "array")
|
|
|
Print element in array: echo ${array[0]}, echo ${array[1]}
|
|
|
Expand all elements of array: printf ${array[@]}
|
|
|
Delete array value: unset ARRAY[1]
|
|
users
|
|
which <filename>
|
|
Display and manage top processes: top
|
|
|
Display processor related statistics: mpstat 1
|
|
|
Display virtual memory statistics: vmstat 1
|
|
|
Display the last 100 syslog messages: tail 100 /var/log/messages
|
|
|
Monitor all traffic on port 80: tcpdump -i eth0 'port 80'
|
|
|
List files opened by user: lsof -u user
|
|
|
Display free and used memory ( -h for human readable, -m is MB, -g is GB): free -hmg
|
|
ls [list files in a directory]
|
|
ls -al [Formats files in a list and shows hidden files
|
|
cd (dir) [Change directory]
|
|
pwd [Show current directory]
|
|
more (file) [Outputs contents of a file]
|
|
firewall-cmd --add-service='service name' -Adds system service to firewall protection
|
|
sudo dnf install <package> -useful for installing new packages from the command line
|
|
sudo dnf upgrade <package> -upgrades or updates given package
|
|
sudo dnf remove <package> -removes the selected package
|
|
if []; then echo "" exit 1 . -if-then-exit commands for scripts
|
|
cron -e (Find timed services)
|
|
|
crontab -l 2>/dev/null | grep -q "0 0 * crontab <command> (Ensure crontab is not outputting any else but the job to run)
|
|
df -h (Shows used disk space of certain file or directory)
|
|
tar -x (Exract files) -v (verbose) z (zipped file) -f (use tar archive for operation)
|
|
jupyterhub --generate-config (Generates jupyterhub_config.py)
|
|
|
jupyterhub -f /etc/jupyterhub/jupyterhub_config.py (Start jupyterhub using config)
|
|
|
c.JupyterHub.ip = '192.168.1.2' c.JupyterHub.port = 443 (Change IP and Port in config FIle)
|
|
reboot
|
|
sudo dnf install ntp -y
|
|
|
sudo dnf install krb5-libs krb5-server krb5-workstation
|
|
|
Edit /var/kerberos/krb5kdc/kadm5.acl Change /admin@EXAMPLE to /admin
|
|
|
sudo /usr/sbin/kdb5_util create -s
|
|
Example to test if directory was created: test -d /tmp/temp_dir
|
|
uptime
|
|
wget -c [URL]
|
|
find . -mtime -1 -type f -print | xargs tar --create --gzip --file=$DESTDIR$FIL> : Reads items from the standard input
|
|
Ctrl+C = Ends current process
|
|
Ctrl+Z = Stops current process, but can be resumed
|
|
Ctrl+D = Log out of current session
|
|
exit = Log Out of current session
|
|
Up/Down Arrows = Navigate through previous commands
|
|
ipconfig -a -displays all networks and interfaces
|
|
ping host -send a ping signal to the host
|
|
ifconfig eth0 -displays eth0 address and details
|
|
#!/bin/bash -normal shebang of commented file
|
|
echo "Hello World!" -display line of text
|
|
#comment -# is the standard way to command in text editor
|
|
variable_name="Sebastiaan" -standard way to establish variables
|
|
find -mtime (Files access within certain time) -type (Look for specific file type)
|
|
$HOME
|
|
if command -v "$1" >/dev/null; then
|
|
if [ -v "$1" ]; then
|
|
Add this command to JupyterHub config: from oauthenticator.google import GoogleOAuthenticator c.JupyterHub.authenticator_class = GoogleOAuthenticator
|
|
|
Customize domain name: c.GoogleOAuthenticator.hosted_domain = ['jupyterhub.com']
|
|
|
Installing oauth: dnf install oauthenticator
|
|
Create an alias example: alias 11='ls --color=auto'
|
|
|
Chec k whether command is an alias: type -a 11
|
|
Create function in command line example: bash$ home() { printf '%s\n' "$HOME" ; }
|
|
|
-- in a function: The option terminator string
|
|
|
"$@" expands to all of the arguments given to the function: printf '%s\n' "$@"
|
|
|
Save defined fucntion in bash: declare -f home
|
|
|
When writing functions in scripts, it is best to instantiate them at the top of the script so no errors are produced.
|
|
Secure copy example.txt to the /tmp folder on server: scp example.txt server:/tmp
|
|
|
Copy .zip files from server to the local /tmp folder: scp server:/var/www/.zip /tmp
|
|
|
Copy all files and directories recursively from server: scp -r server:/var/www /tmp
|
|
|
Synchronize /home to /home/.backups: rsync -a /home /backups/
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.