Overview
- Note the linux commands I need to use.
Users Management
ACTIVATE The Added Group Without Login
$ newgrp [-] [group]
ADD The User & Password
$ sudo useradd -m -s /bin/bash -d [home_dir] -G [group] [username]
$ sudo passwd [username]
$ useradd -p $(openssl passwd -1 password) -m -s /bin/bash -d [home_dir] -G [group] username
BATCH Comment & Uncomment
CHANGE The Mode Of Files And Directories
$ chmod [-cfvR] [--version] mode file...
e.g.
$ chmod 777 file
CHANGE The Owner Of The File
$ chown -R [username]:[groupname] [filename]
CHANGE The User’s HOME_DIR
$ sudo usermod -d /new/home/path [username]
CHANGE The User’s Info
$ sudo usermod -c [New User Info] [USERNAME]
CHANGE The User’s Name
$ sudo usermod -l [new_username] [old_username]
CHANGE The Group’s Name
$ sudo groupmod -n [NEW_GROUPNAME] [OLD_GROUPNAME]
CHANGE The Hostname / Computer Nmae
$ hostnamectl set-hostname [new hostname].
CHANGE / SETUP The User’s Home Directory
$ usermod -d [home directory] [username]
$ usermod -d /home/jenkins jenkins
$ echo $HOME
DELETE The User’s Account
$ sudo deluser [username]
FIND The Process Name Via PID
$ sudo ps -fp [PID]
FIND The Current Location
- It shows the current directory path
$ pwd
/home/rpiauto
FIND The OS Info
- To identify which OS platform in your docker container
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
or
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
INTRODUCE The Common Groups
LIST Users
$ cat /etc/passwd
LIST Groups And Belonged Users
$ cat /etc/group
LIST The Groups That The User Has Joined
$ groups [username]
[username] : [list of groups]
REMOVE The User From The Group
$ sudo deluser [username] [group]
SET Number In Vim Editor Permanently
$ touch ~/.vimrc
$ vim ~/.vimrc
$ set number
Users Management
- How to Create Users in Linux (useradd Command)
- How to Remove or Delete a User in Linux
- useradd command in Linux with examples
- How To Change The HOME_DIR Of User
- How To Change The USERNAME In Linux
- How To Rename a Group in Linux
- Understanding /etc/passwd file fields
- Change User Info on the Command Line
- When trying to change username, terminal tells me user is currently used by process
- 5 Ways to Change Hostname on Linux - wikiHow
- How to Change Hostname on Ubuntu
- Linux “chmod” Commands