Learning Linux!
Hello!
I’ve been taking the LinuxCBT Ubu12x Edition course and learned a few useful tricks that I would like to share here!
Please note that the following content has been tested on Ubuntu 18.04.4 LTS.
Generating SSH Keys
- Open a Terminal.
-
Run the following command, replacing
johnybravo@email.com
with your email address.ssh-keygen -t rsa -b 4096 -C “johnybravo@email.com”
This command will generate a public-private key pair using RSA encryption with a key size of 4096 bits.
-
You will be asked to enter a location to save the key, press Enter to select the default location:
Enter file in which to save the key (/home/user/.ssh/id_rsa):
-
You will now be asked to enter a passphrase to secure your SSH key. This is useful if you plan to add your key to a SSH user-agent:
Enter passphrase (empty for no passphrase)
Enter same passphrase again:
Using an SSH user agent, you will only have to authenticate using the passphrase once per-session. If you are using a personal computer, you can choose an empty passphrase for a password-less SSH experience. However this is not recommended.
-
Run the following command to check whether the keys were generated.
ls ~/.ssh
You should see two files:
id_rsa
: the private keyid_rsa.pub
: the public key
- [OPTIONAL] If you are on a Linux or Mac system, you can add your SSH key to the default
ssh-agent
using the following command:ssh-add ~/.ssh/id_rsa
-
[OPTIONAL] To add your public key to a SSH-enabled server, run the following command replacing
user
with the remote username andIP
with remote server’s IP address:ssh-copy-id -i ~/.ssh/id_rsa user@IP
All the stats!
-
Run the following command for detailed hardware information information including vendor name, chassis type, motherboard specification, CPU specification, RAM specification, all connected USB devices, display specification, all connected PCI devices and much more:
lshw
For a more elaborate listing of hardware specification it is recommended to run it with
sudo
priviliges:sudo lshw
-
Run the following command for information on all network interface cards and their layer 3 addresses:
ip address show
-
Run the following command for information on all network interface cards and their layer 2 addresses:
ip link show
-
Run the following command for detailed CPU information including number of cores, number of threads, cache sizes, minimum frequency, maximum frequency and much more:
lscpu
-
Run the following command to final all PCI devices and their bus IDs:
lspci
-
Run the following command to final all USB devices and their bus IDs:
lsusb
May I have your PERMISSION please!
-
Run the following command to take ownership of a file, replacing
johnybravo
with the new owner’s username andfile.txt
with the file whose owner is to be updated:chown johnybravo file.txt
-
Run the following command to take ownership of a file, replacing
admingroup
with the new owner’s groupname andfile.txt
with the file whose owner is to be updated:chown :admingroup file.txt
-
Run the following command to update both the owner and group-owner of a file, replacing
admingroup
with the new owner’s groupname,johnybravo
with the new owner’s username andfile.txt
with the file whose owner is to be updated:chown johnybravo:admingroup file.txt
-
Run the following command to change file permissions, replacing
file.txt
with the file whose permissions are to be updated:chmod 777 file.txt
Note that the first digit represents the permissions for the user owner, the second digit represents the permissions for the group owner and the third digit represents the permissions for the world.
Each digit can be calculated as the sum of the following permissions:
Permission Value No permission 0 Execute 1 Write 2 Read 4