| alias | |
|---|---|
| tag | CodeNotebook |
cd path/to/dir to change directory, cd .. to move one dir up
pwd to write out current absolute path e.g. /home/user/.ssh
ls to write out the content of current dir (possible append with path ls some/place), popular options include:
-afor all,-Afor all without.and..-lfor long format,-gjust without author,-Gwithout group-Fto append one of*/=>@|)to entries--color=alwaysto show colours-hfor man-readable, useful with-land-s-sprint size in blocks-rto reverse order-Ssort by size, descending-tsort by time creation, descending-cltsort by ctime (modification), descending-utsort by access time, descending-Uno sorting-Xsort by extensions-Rfor recursive listing-nis like-lbut numbers instead of strings
to find software info about current OS uname -a
to find info about current release lsb_release -a
Install neofetch for pretty print of basic HW and SW info neofetch
which command to find the path to command
type command to find what kind of command is, whether programme, executable or shell built-in
Utilized by find <starting-directory> <options> <search term> and most basic being:
find . -name my-fileOther options are:
-inamefor case-insensitivity-notfor negation-typefollowed bydirectory,file,link,character andblock device-deleteto delete the found files-size <size> <unit>, possible useckMGfor byte, kilo, mega, giga10M-userby user-groupby group-permby perm (alternative-emptyfor empty files,-execfor executables and-readfor readable)
Alternative to find is locate which indexes your whole system and runs the command on the database. You may install it and run it via following:
sudo apt-get update
sudo apt-get install mlocate
sudo updatedbTODO: write a bit more about these
chmod
chown -Rv user[:group] FILE
chgrg
disown -a && exit
For simple command persistence, use screen, then run your command and leave with CTRL+A D. To come back, use screen -r. If you have more screens running, it'll list all of them with last command and let you choose one of them.
it certainly exists.
For system state:
systemctl statusshow current statussystemctl --failedshow failed units
Checking unit status:
systemctl status unitincludes whether it's runningsystemctl is-enabled unit
Management, all requires root/sudo:
systemctl start unitsystemctl stop unitsystemctl restart unitsystemctl reload unit(reloads unit's config)systemctl daemon-reload(scan for changes)
Enabling units i.e. starting at boot
systemctl enable unitsystemctl enable --now unitto enable and start right awaysystemctl disable unit
In etc/systemd/system/your.service we write following
[Unit]
Description=Your service here
After=network.target #what part of system is required
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always #on-failure option
RestartSec=1 #interval before restarting
User=YourUser #important for file access
ExecStart=/path/to/bin command args
[Install]
WantedBy=multi-user.targetand start it with systemctl start your.service.
df -HT,lsblk (no SU), fdisk -l, blkid
!BE CAREFUL! Altho fdisk need confirm to write, use print to triple check
sudo fdisk /dev/sdx
mkfs.<type> [-j] /dev/sdxn
e2label /dev/sdxn "label name"
to mount sudo mount /dev/sdxn /where/to
in /etc/fstab add entry and do mount -a
#FS,LABEL= or UUID= /mnt/pnt/ fstype options dump pass
LABEL=MY_BACKUP /mount/point ext4 defaults 1 2
mkdir -p /mnt/ram
mount -t tmpfs tmpfs /mnt/ram -o size=8192M
nmcli with one of the following allows you to list, modify, manage connections & device or even allows you to use wifi to scan network, set hotspots or show password
- g[eneral] NetworkManager's general status and operations
- n[etworking] overall networking control
- r[adio] NetworkManager radio switches
- c[onnection] NetworkManager's connections
- d[evice] devices managed by NetworkManager
- a[gent] NetworkManager secret agent or polkit agent
- m[onitor] monitor NetworkManager changes
E.g. to set wifi to connect automatically, do following:
nmcli connection modify NAME/UUID connection.autoconnect yesTODO: write a bit more about how to use either of them
All firewall manipulation will require admin privileges.
Printing current rules is done via iptables -L, add -v for more verbosity; iptables -S for exact command wording
To save the rules, use:
sudo apt install iptables-persistent
sudo netfilter-persistent saveIf you're setting up service in Oracle Cloud, do not forget to allow particular ports and ips in secure list via webUI. However each Ubuntu and like other image with IPTables need to run following commands to make it work since the defaults make traffic into arbitrary REJECT jump. If you wanna do it right way, add the rules with -I FLOW 5 <rest-of-rule> (or any number before the jump rule specified bellow).
iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
iptables -D FORWARD -j REJECT --reject-with icmp-host-prohibitedFIXME: wording To add traffic through, modify following; for Oracle Cloud VM Firewall (INPUT on interface ens3, TCP/IP at port 80, state NEW, ESTABLISHED)
iptables -A INPUT -i ens3 (NIC) -p tcp (protocol) --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT- https://docs.rockylinux.org/gemstones/string_color/
- https://opensource.com/article/19/9/linux-terminal-colors
- https://blog.icod.de/2023/11/26/how-to-have-a-nice-looking-prompt-in-rocky-linux/
- https://unix.stackexchange.com/questions/148/colorizing-your-terminal-and-shell-environment
- https://student.cs.uwaterloo.ca/~cs452/terminal.html
#custom
PS1='\e[33;1m\u\[\033[00m\]@\[\033[01;32m\]\h\[\033[00m\]: \[\033[01;34m\]\W\e[0m\$ '
#default deb
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '