General Useful Linux Commands

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#### Sudo is not installed by default on Debian, so install it:
apt install sudo
### Add a user account
sudo useradd -m nameofaccounttoadd
#### Sometimes there is a sudoers list
/etc/sudoers
#### Sometimes there is an ssh users list
etc/ssh/sshd_config
### Change the password for a user
sudo passwd nameofaccounttoadd
<password>
#### Add a user to the sudo group
sudo usermod -a -G sudo nameofaccounttoadd
#### Set the expiry date on an account (at 0000 hrs)
usermod -e 2018-10-24 accountname

Powershell on Linux

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh
# Enable conencting to PSSession on Linux box
SSH KeyGen
# Log on to target machine
ssh-keygen
cat ~/.ssh/id_rsa.pub