- Changed the hostname by editing
/etc/hostnameand/etc/hosts
(will act as remote) VirtualBox Ubuntu Server 20.04
- hostname:
Ariana - login/user:
haiji - ip:
192.168.225.26
(will act as local) Host Machine Ubuntu Desktop 20.04
- hostname:
Pavilion - login/user:
devpogi - ip:
192.168.225.44
- I had already changed the timezone on Day 1 with
sudo dpkg-reconfigure tzdatainstead oftimedatectl. Yet, I usedtimedatectlto see the current setting about timezone andtimedatectl list-timezonesto see timezones. India's timezone will be available under Asia/Kolkata.
The major practical effects of this are (1) the timing of scheduled tasks, and (2) the timestamping of the logs files kept under
/var/log. If you make a change, there will naturally be a "jump" in the dates and time recorded.
- I noticed the jump in timestamp in the
/var/log/auth.log(which records any usage ofsudoalong with other logs.)
-- **START OF THIS FILE** --
Sep 7 08:56:59 ariana useradd[717]: new group: name=haiji, GID=1000
Sep 7 08:56:59 ariana useradd[717]: new user: name=haiji, UID=1000, GID=1000, home=/home/haiji, shell=/bin/bash, from=none
.
.
.
Sep 7 08:56:59 ariana useradd[717]: add 'haiji' to group 'sudo'
.
.
.
Sep 7 11:05:30 ariana sshd[1009]: pam_unix(sshd:session): session closed for u
ser haiji
-- **JUMP HAPPENED HERE** --
Sep 7 15:38:50 ariana systemd-logind[649]: New seat seat0.
Sep 7 15:38:50 ariana systemd-logind[649]: Watching system buttons on /dev/inp
ut/event0 (Power Button)
-
Saw
/etc/shadowfile and read a little aboutcryptandshadowfrom the man pages. Saw the encrypted password for haiji user. -
99999 in the maximum password age field in
/etc/shadowfile for login user (haiji, in my case) is approximately 273 years.
A password field which starts with an exclamation mark means that the password is locked. The remaining characters on the line represent the password field before the password was locked. If the password field contains some string that is not a valid result of crypt(3), for instance ! or *, the user will not be able to use a unix password to log in (but the user may log in the system by other means).
from shadow man page.
u/komodo says that,
On AWS EC2, you will find that all of your password hashes in
/etc/shadoware*or!I've read that*means that the user is completely disabled for login.!indicates the user has never been given a password, which is the case for theubuntuaccount. If you'd like you can set a password withsudo passwd ubuntu. If you look at/etc/shadowafterwards you will see a proper hash.though I cannot experiment with that because I don't have an aws ec2.
-
sudo -iwill use home dir as/rootand will not be corrupted by user's env variables. However,sudo -swill use user's home dir (example, /home/devpogi) and will have user's env variables. Both will have root's PATH. -
What's worth keeping in mind here is that the-scommand line option gives you a shell with root privileges, but you don't get the root environment - it's your.bashrcthat gets sourced. This means that, for example, in the new shell thatsudo -sruns, executing the whoami command will still return your username, and not 'root'.
sudo -sgave me root onwhoamiand gave me/rootonecho $HOME, I am not sure about which.bashrcgot sourced, but instead of changing to/root, it remained at the last working dir (i.e. the dir before execution ofsudo -scommand).
-
sudo session remains active for 15-mins by default. Suppose during this session, you have to give someone access to your terminal, but you don't want them to be able to use sudo. What will you do?
sudo -kis used to revoke root privileges, and will prompt for password at the next occurence of sudo.
View the discussion as html page (in discord default theme)
generated using DiscordChatExporter
plain html text
Takeaways:
- Use sudo prefixed commands instead of logging into a temporary root shell with
sudo -i. - Create a shell script if I need to do a series of sudo commands, this will save from errors (when directly writing sudo in terminal)
- I can copy
~/.bashrcto/root/.bashrcbut it is not best practice to use the root login shell. - Again, I can login from tty with root account (remember the
!in encrypted password field in/etc/shadow) but that is not preferred.