Example: biology

Ubuntu Server CLI pro tips

Ubuntu Server CLI pro tipsNetworkingGet the IP address of all interfacesnetworkctl statusDisplay all IP addresses of the hosthostname -IEnable/disable interfaceip link set <interface> upip link set <interface> downManage firewall rulesenable firewall: sudo ufw enablelist rules: sudo ufw statusallow port: sudo ufw allow <port>deny port: sudo ufw deny <port>Connect remotely through SSHssh <user>@<host IP>Automatically detect and ban abusive IP addressessudo apt install fail2banShow banned IP addressessudo fail2ban-client statussudo fail2ban-client status <jail>Get the support status for installed packagesubuntu-support-statusEnable kernel live patchingsudo snap install canonical-livepatchsudo canonical-livepatch enable <token>Visit to get a free token for up to 3 LTSU buntu LTSU buntu LTSU buntu LTSH ardware and maintenance updatesMaintenance updates201420152016201720182019202120222 023202420252020202620272028202920302031 Interim releaseExtended security maintenance for customersUbuntu release cadenceFilesList fileslsList files with permissions and datesls -alCommon file

Ubuntu Server CLI pro tips Networking Get the IP address of all interfaces networkctl status Display all IP addresses of the host hostname -I Enable/disable interface ip link set <interface> up ip link set <interface> down Manage firewall rules enable firewall: sudo ufw enable

Tags:

  Tips, Ubuntu, Server, Ubuntu server cli pro tips

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Ubuntu Server CLI pro tips

1 Ubuntu Server CLI pro tipsNetworkingGet the IP address of all interfacesnetworkctl statusDisplay all IP addresses of the hosthostname -IEnable/disable interfaceip link set <interface> upip link set <interface> downManage firewall rulesenable firewall: sudo ufw enablelist rules: sudo ufw statusallow port: sudo ufw allow <port>deny port: sudo ufw deny <port>Connect remotely through SSHssh <user>@<host IP>Automatically detect and ban abusive IP addressessudo apt install fail2banShow banned IP addressessudo fail2ban-client statussudo fail2ban-client status <jail>Get the support status for installed packagesubuntu-support-statusEnable kernel live patchingsudo snap install canonical-livepatchsudo canonical-livepatch enable <token>Visit to get a free token for up to 3 LTSU buntu LTSU buntu LTSU buntu LTSH ardware and maintenance updatesMaintenance updates201420152016201720182019202120222 023202420252020202620272028202920302031 Interim releaseExtended security maintenance for customersUbuntu release cadenceFilesList fileslsList files with permissions and datesls -alCommon file

2 Operationscreate empty: touch <filename>create with content: echo "<content>" > <filename>append content: echo "<content>" >> <filename>display a text file: cat <file>copy: cp <file> <target filename>move/rename: mv <file> <target directory/filename>delete: rm <file>Create a directorymkdir <directory>PackagesSearch for packagesapt search <string>snap find <string>List available updatesapt list --upgradableApply all available updatessudo apt update && sudo apt upgradeInstall from the Ubuntu archive:sudo apt install <package>Install from the snap store:sudo snap install <package>Which package provides this file?sudo apt install apt-filesudo apt-file updateapt-file <filename or command>Create directories recursivelymkdir -p <directory1>/<directory2>Delete a directory recursivelyrm -r <directory>Quick file searchlocate <q>Search string in filegrep <string> <filename>Search string recursively in directorygrep -Iris <string> <directory>SecurityShow which users are logged inwGet password expiration date for <user>chage -l <user>Set password expiration date for <user>sudo chage <user>Lock a user accountsudo passwd -l <user>Unlock a user accountsudo passwd -u <user>List open ports and associated processessudo netstat -tulpn2020 OpenStackInstall OpenStack and launch an instancesudo snap install microstack --classicsudo Horizon dashboard is available at credentials.

3 Admin / keystoneMore MicroStack help at files modified in the last n minutesfind <directory> -mmin -<n> -type f eg. find . -mmin -5 -type fShow only the nth columncol<n> <separator> <filename>eg. col2 , file paginatedless <filename>Display first n lineshead -n <n> <filename>Display last n linestail -n <n> <filename>Follow file content as it increasestail -f <filename>SystemDisplay kernel versionuname -rGet disk usagedf -hGet memory usagecat /proc/meminfoGet system timetimedatectl statusSet system timezonetimedatectl list-timezonessudo timedatectl set-timezone <zone>Get all running servicessystemctl --state runningStart or stop a serviceservice <service> start/stopMonitor new logs for a servicejournalctl -u <service> --since now -fPack a directory into an archivezip: zip -r <target> <source dir> : tar cvzf <target>.

4 <source dir>Unpack an archivezip: unzip <zip file> : tar xf < file>Copy file to remote serverscp <filename> scp Copy directory recursively from remote serverscp -r <user@ Server >:<source> <destination>eg. scp -r /tmpGet the list of recent loginslastDisplay running processeshtopKill process by idkill <process id>Kill process by namepkill <process name>Run command in the background<command> &Display background commandsjobsBring command <n> to the foregroundfg <n>Kubernetes and containersInstall MicroK8s and list available add-onssudo snap install microk8s --wait-readyEnable a MicroK8s <service>View MicroK8s nodes and running get nodes get servicesMore MicroK8s help at a LXD containerlxd initlxc launch <container name>VirtualisationInstall Multipass and launch an Ubuntu VMsudo snap install multipass --classicmultipass launch <image> --name <VM name>Omitting <image> will launch a VM with the latest Ubuntu LTSFind available imagesmultipass

5 FindOr another distrolxc launch images:centos/8/amd64 <container name>Get a shell inside a LXD containerlxc exec <name> -- /bin/bashPush a file to a LXD containerlxc file push <filename> <container name>/<path>Pull a file from a LXD containerlxc file pull <destination> <container name>/<file path>More LXD help at existing VMsmultipass listGet a shell inside a VMmultipass shell <VM name>More Multipass help at Server CLI pro tips2020


Related search queries