Skip to content
DannWu edited this page Nov 23, 2022 · 14 revisions

server


#problem with wired Ethernet unmanaged #edit /etc/NetworkManager/NetworkManager.conf [main] plugins=ifupdown,keyfile

[ifupdown] managed=true

[keyfile] unmanaged-devices=*,except:type:wifi,except:type:gsm,except:type:cdma,except:type:wwan,except:type:ethernet,except:type:vlan

[device] wifi.scan-rand-mac-address=no

#save the file, and run

  • sudo systemctl restart network-manager

#check the device status

  • sudo nmcli device status

#keep the computer from sleeping

  • sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

#Set the global environment by editing file /etc/environment, one environment per line, reload the file by running

  • source /etc/environment
  • echo $variable_name

#Local or user environment, Ubuntu page recommends editing ~/.profile; when bash is started as a login shell, Bash will prefer ~/.bash_profile; the third alternative is ~/.bashrc

#system infomration #kernel/operating system/CPU info in brief.

  • head -n 1 /etc/issue

#see the ubuntu version,same to

  • cat /etc/issue

#hostname

  • lspci -tv

#list all PCI devices

  • lsusb -tv

#list all USB devices

  • lsmod

#list loaded kernel modes

  • env

#environment variable, Resources

  • free -m

#see the usage of memory and swap

  • df -h

#the usage of partitions

  • du -sh

#see the size of the directory in M.

  • grep MemTotal /proc/meminfo

#total size of RAM

  • grep MemFree /proc/meminfo

#system running time,users,load average

  • cat /proc/loadavg

#load average, Disk and Partition

  • mount | column -t

#mount info about partitions

  • fdisk -l

#list all partitions,need root permission

  • swapon -s

#list all swap partitions

  • hdparm -i /dev/sda

#Network

  • ifconfig

#list IP informations

  • route -n

#list route tables

  • netstat -lntp

#list listening ports

  • netstat -antp

#check port usage

  • netstat -peanut

#Process

  • ps -ef

#list all processes

  • top

#list processes and usage of system resource

  • id username

#list the user info.

  • last

#list login record

  • cut -d: -f1 /etc/passwd

#list all users

  • cut -d: -f1 /etc/group

#check nr of cpus

  • lscpu; - nproc; -/proc/cpuinfo

#open port on Ubuntu

  • sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  • sudo apt-get install iptables-persistent

#find things on Ubuntu

  • find / -name "somthing*" 2>/dev/null #the last part silence the permission errors
  • find / -iname "somethingtxt" 2>/dev/null #iname for the case insensitive search


#https://stackoverflow.com/questions/50249002/docker-still-show-the-version-after-after-its-purge #delete packages from Ubuntu, after apt-get purge and still trace of the software are left

  • whereis docker #when the files showed after the above command, use
  • dpkg -S /path/to/the/file #when the package is shown, use apt-get purge to remove it
Clone this wiki locally