On a new ubuntu system, you probably want to change some defaults to something more appropriate. Select the options below which you want for the customising of your system. These suggestions are more appropriate to systems running on AWS or Rasperry-Pi than having done a custom install from media.
Please do not blindly copy and paste these instructions. Check, modify and use as appropriate to your system. Skip inappropriate bits
# Get "Administrator" access sudo su - # Update packages to the latest to fix bug and security issues. apt-get update && apt-get -y dist-upgrade && apt -y autoremove # If the above has included kernel packages, then it is also probably a good idea to reboot: shutdown -r now # Set the clock to your time zone timedatectl list-timezones timedatectl set-timezone Africa/Lagos timedatectl set-ntp yes timedatectl status # You can edit / set time servers in the file /etc/systemd/timesyncd.conf if required. # If the time sync service ever needs restarting it can be dne with: systemctl restart systemd-timedated # Set locale info, this will set things such as date formats dpkg-reconfigure keyboard-configuration dpkg-reconfigure locales # Set default running mode to be non-graphical # Skip this if you do want a graphical interface! systemctl enable multi-user.target systemctl set-default multi-user.target # Create a new admin user, and test this before deleting the standard one # The dialout group is required if this user accesses Arduino devices over the serial interface useradd -c "Nelson E Noo" -m -G adm,users,sudo,dialout nelson passwd nelson su - nelson -c ssh-keygen # You can add groups to the user at a later date by using usermod # -a to indicate "Add" group not "overwrite" (default) of the comma separated group list -G usermod -a -G wheel nelson # RedHat/Oracle-Linux usermod -a -G sudo nelson # Ubuntu/Debian # update the keyfile to accept logins with by adding public key to this file vi /home/nelson/.ssh/authorized_keys chown nelson /home/nelson/.ssh/authorized_keys chmod 0600 /home/nelson/.ssh/authorized_keys # After verifying the new user works and can gain sudo access delete the standard default user # If you want a rpi system to default to autologged in graphical mode, then perhaps skip this step. userdel pi # Add packages you will find useful # Suggest using either xymon or xymon-client, depending if this is a monitoring node or client apt-get install nmon apache2 python3 python3-serial xymon-client unattended-upgrades # For Raspberry-Pi running on a private network you may want a Fixed IP address rather than DHCP nmcli nmcli device show nmcli con mod ethernet ipv4.addresses 192.168.1.10/24 nmcli con mod ethernet ipv4.gateway 192.168.1.1 nmcli con mod ethernet ipv4.dns "192.168.1.1 8.8.8.8 8.8.4.4" nmcli con mod ethernet ipv4.dns-search aardvark.net nmcli con mod ethernet ipv4.method manual nmcli con up ethernet
Technically we will leave the PS1 prompt untouched, but make use of another variable called the PROMPT_COMMAND, which is run before printing the PS1 value. By adding some colour and a timestamp to the command line, we clearly delineate where we have run a new command. The colour coding can serve as a visual bell to indicate which environment is being worked on. Also for someone working to resolve an incident, they get access to time stamps as to when things were done if they are saving a log of their screen.
Lets assume we use letters 1-3 to indicate physical location, 4-6 the function and the 7th letter of a machine name to indicate if it is in production, test, development or management environments. The a name like lagmonm01 might refer to the first (or perhaps only) instance of a Lagos based monitoring server. Then we can set the colors adding the following to /etc/bash.bashrc follows:
context=`uname -n | cut -c 7` # # Use state to switch colour settings # Prod = WHITE name on RED # Dev = BLACK name on GREEN # TEST = YELLOW name on BLUE # Other= BLACK name on YELLOW # case $context in "p") HIGH="^[[97;41m" ;; "d") HIGH="^[[30;42m" ;; "t") HIGH="^[[93;44m" ;; *) HIGH="^[[30;43m" ;; esac STD="^[[0m" export STD HIGH export PROMPT_COMMAND="echo \${HIGH}\[\$(date +%Y-%m-%d\ %H:%M:%S)\]\${STD} "
Note the "^[" characters are a single escape character rather than two characters. Using the vi editor you can get this by using CTRL-V ESC.
Since the colour contraol caharacters are kept out of the PS1 prompt, the ability to edit and view your command history remain unchanged.
Thank you for visiting camelthorn.cloud | Home |