Ubuntu Server CLI Pro Tips

Ubuntu Server CLI Pro Tips

Ubuntu Server CLI pro tips Networking Packages Files Get the IP address of all interfaces Search for packages List files Create directories recursively networkctl status apt search <string> ls mkdir -p <directory1>/<directory2> BASIC snap find <string> Display all IP addresses of the host List files with permissions and dates Delete a directory recursively List available updates hostna m e -I ls -al rm -r <directory> apt list --upgradable Enable/disable interface Apply all available updates Common file operations Quick file search create empty: touch <filename> locate <q> ip link set <interface> up sudo apt update && sudo apt upgrade ip link set <interface> down create with content: echo "<content>" > <filename> Install from the Ubuntu archive: append content: echo "<content>" >> <filename> Search string in file Manage firewall rules sudo apt install <package> display a text file: cat <file> grep <string> <filename> enable firewall: sudo ufw enable copy: cp <file> <target filename> Install from the snap store: move/rename: mv <file> <target directory/filename> Search string recursively in list rules: sudo ufw status sudo snap install <package> delete: rm <file> directory allow port: sudo ufw allow <port> grep -Iris <string> <directory> deny port: sudo ufw deny <port> Which package provides this file? Create a directory sudo apt install apt-file mkdir <directory> Connect remotely through SSH sudo apt-file update ssh <user>@<host IP> apt-file <filename or command> Security Ubuntu release cadence Show which users are logged in Automatically detect and ban w abusive IP addresses Ubuntu .04 TS sudo apt install fail2ban Get password expiration date for Ubnt 9.10 <user> Show banned IP addresses Ubnt 9.04 chage -l <user> sudo fail2ban-client status Ubuntu 8.0 TS Set password expiration sudo fail2ban-client status <jail> Ubuntu 6.0 TS date for <user> Get the support status for installed sudo chage <user> packages Ubuntu 4.0 TS Lock a user account ubuntu-support-status 2014 2015 2016 2017 2018 2019 2020 202 2022 2023 202 2025 202 202 2028 2029 200 2031 sudo passwd -l <user> Enable kernel live patching Unlock a user account sudo snap install canonical-livepatch Hardware and maintenance pdates Interim release sudo passwd -u <user> sudo canonical-livepatch enable <token> Maintenance pdates Extended security maintenance for customers List open ports and associated Visit ubuntu.com/livepatch to get a processes free token for up to 3 machines. sudo netstat -tulpn 2020 Ubuntu Server CLI pro tips Files Kubernetes and containers Find files modified in the last n minutes Pack a directory into an archive Install MicroK8s and list available add-ons Or another distro find <directory> -mmin -<n> -type f zip: zip -r <target> <source dir> sudo snap install microk8s --classic lxc launch images:centos/8/amd64 eg. find . -mmin -5 -type f t a r.g z: tar cvzf <target>.tar.gz <source dir> microk8s.status --wait-ready <container name> Show only the nth column Unpack an archive Enable a MicroK8s add-on Get a shell inside a LXD container ADVANCED col<n> “<separator>” <filename> zip: unzip <zip file> microk8s.enable <service> lxc exec <name> -- /bin/bash eg. col2 “,” foo.csv t a r.g z: tar xf <tar.gz file> View MicroK8s nodes and running services Push a file to a LXD container Display file paginated Copy file to remote server microk8s.kubectl get nodes lxc file push <filename> less <filename> scp <filename> <user@server>:<destination> microk8s.kubectl get services <container name>/<path> eg. scp config.yaml [email protected]:/config Display first n lines More MicroK8s help at microk8s.io/docs Pull a file from a LXD container head -n <n> <filename> Copy directory recursively lxc file pull <destination> from remote server Launch a LXD container <container name>/<file path> Display last n lines scp -r <user@server>:<source> <destination> lxd init tail -n <n> <filename> eg. scp -r [email protected]:/config /tmp lxc launch ubuntu:18.04 <container name> More LXD help at linuxcontainers.org/lxd Follow file content as it increases tail -f <filename> Virtualisation Install Multipass and launch List existing VMs System an Ubuntu VM multipass list sudo snap install multipass --classic Display kernel version Get the list of recent logins multipass launch <image> --name <VM name> Get a shell inside a VM uname -r last multipass shell <VM name> Omitting <image> will launch a VM with Get disk usage Display running processes the latest Ubuntu LTS More Multipass help at df -h htop discourse.ubuntu.com Find available images Get memory usage Kill process by id multipass find cat /proc/meminfo kill <process id> Get system time Kill process by name timedatectl status pkill <process name> OpenStack Set system timezone Run command in the background Install OpenStack and launch timedatectl list-timezones <command> & an instance sudo timedatectl set-timezone <zone> sudo snap install microstack --classic Display background commands sudo microstack.init Get all running services jobs microstack.launch systemctl --state running Bring command <n> to the foreground The Horizon dashboard is available at 10.20.20.1 Start or stop a service fg <n> Default credentials: admin / keystone service <service> start/stop More MicroStack help at microstack.run/docs Monitor new logs for a service journalctl -u <service> --since now -f 2020.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us