Thursday, December 27, 2018

Ubuntu Basic Configuration Commands


1. Update / Upgrade Commands
  • sudo apt-get update : In a nutshell, apt-get update doesn't actually install new versions of software. Instead, it updates the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories.
  • sudo apt-get upgrade : will fetch new versions of packages existing on the machine if APT knows about these new versions by way of apt-get update. An update must be performed first so that apt-get knows that new versions of packages are available.
  • sudo apt-get dist-upgrade: will do the same job which is done by apt-get upgrade, plus it will also intelligently handle the dependencies, so it might remove obsolete packages or add new ones. 

Note: we can combine commands with && signs, such as:
  • sudo apt-get update && sudo apt-get dist-upgrade


2. Install and start SSH service
  • sudo apt-get install openssh-server
  • sudo service ssh start

Verify with netstat command:
-t: tcp
-u: udp
-l: listening
-p: program/pid
-n: numeric
[email protected]:~$ netstat -tulpn
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -               
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -               
[email protected]:~$ 



3. Allow Root log in and set Root password
[email protected]:~$ sudo view /etc/ssh/sshd_config 
PermitRootLogin yes
[email protected]:~$ sudo service ssh restart
set up root password
[email protected]:~$ sudo su - root
[email protected]:~# passwd root
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

4. Configure DNS and IP

[email protected]:~# view /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens160
iface ens160 inet static
        address 172.27.3.3
        netmask 255.255.255.0
        network 172.27.3.0
        broadcast 172.27.3.255
        gateway 172.27.3.1
        dns-nameserver 8.8.8.8
        dns-search foo.org.bar.co
[email protected]:~# service networking force-reload
[email protected]:~# service networking restart


Edit DNS Configuration File:
/etc/systemd/resolved.conf 

Find the DNS section and add your DNS server ip addresses:
DNS= 1.1.1.1 8.8.4.4 192.168.2.1 


5. Configure apt sources
[email protected]:~# view /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
[email protected]:~# apt update
Here it has been set Aliyun source

6.Change Timezone
Check time zone
[email protected]:~# date -R
Thu, 29 Nov 2018 03:53:49 -0500
Modify timezone
[email protected]:~# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Verify
[email protected]:~# date -R
Thu, 29 Nov 2018 16:58:15 +0800

Note: command  'timedatectl'

7. Fix Broken Ubuntu Without Reinstalling it

$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/lib/dpkg/lock
$ sudo rm /var/lib/dpkg/lock-frontend
$ sudo dpkg --configure -a
$ sudo apt clean
$ sudo apt update --fix-missing
$ sudo apt install -f
$ sudo dpkg --configure -a
$ sudo apt upgrade
$ sudo apt dist-upgrade

Last step, 'sudo reboot'


8. Check Ubuntu Version/CPU/Release information

[email protected]:~# getconf LONG_BIT
64

[email protected]:~#  lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic

[email protected]:~# uname -a
Linux wan 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 13:11:22 UTC 2017 x86_64

[email protected]:~# cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i5-4300U CPU @ 2.10GHz
stepping        : 9
microcode       : 0x4e
cpu MHz         : 2712.050
cache size      : 3072 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
bogomips        : 5424.10
clflush size    : 64
cache_alignment : 64
address sizes   : 43 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i5-4300U CPU @ 2.10GHz
stepping        : 9
microcode       : 0x4e
cpu MHz         : 2712.050
cache size      : 3072 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
bogomips        : 5424.10
clflush size    : 64
cache_alignment : 64
address sizes   : 43 bits physical, 48 bits virtual
power management:


9. Install and Configure Samba Server on Ubuntu

9.1 Install Samba

[email protected]:~# apt-get install samba

9.2 Change Configuration file

[email protected]:~# vi /etc/samba/smb.conf

Append following configuration at the end of smb.conf


[share]
        path = /Deepinfar
        available=yes
        browseable = yes
        public = yes
        writeable = yes
        guest ok = no

9.3 Add root user into Samba user list

[email protected]:~# smbpasswd -a root

9.4 Restart Samba service and test from windows
[email protected]:~# smbd start

From windows, you can access the share folder at \\192.168.2.102\share\ with root username and password.


No comments:

Post a Comment