Modified 2019-09-22 by Andrea Censi
A reference of useful Linux commands.
visudo
truncate
curl
wget
Modified 2019-09-22 by Andrea Censi
man
Modified 2019-09-22 by Andrea Censi
This is an interface to the on-line reference manuals. Whenever you meet some unfamiliar commands, try use man certain_command
before Googling. You will find it extremely clear, useful and self-contained.
Modified 2019-09-22 by Andrea Censi
cd
Modified 2019-09-22 by Andrea Censi
Go to the directory you want. If you just use:
$ cd
then you will go to your home directory, i.e., /home/user/
To go up one directory use:
$ cd ..
ls
Modified 2019-09-22 by Andrea Censi
List all the files and documents in the current directory. From ~/.bashrc
, we know some commonly used alias. See more by man ls
.
– la
for ls -a
which will list out all files and documents including the hidden ones(whose name starts with a dot).
– ll
for ls -l
which will display Unix file types, permissions, number of hard links, owner, group, size, last-modified date and filename.
Modified 2019-09-22 by Andrea Censi
sudo
Modified 2019-09-22 by Andrea Censi
Whenever you want to modify system files, you will need sudo
. Commonly touched system files including /etc
, /opt
and so on. Since most of you have followed the guideline to use passwordless sudo, I would recommend that make sure what you are doing with sudo before you execute the command, otherwise you may need to reinstall the system.
visudo
Modified 2019-09-22 by Andrea Censi
Modified 2019-09-22 by Andrea Censi
cp
Modified 2019-09-22 by Andrea Censi
cp fileA directoryB
will copy the file A to directory B. See more by executing man cp
.
mv
Modified 2019-09-22 by Andrea Censi
mv fileA directoryB
will move the file A to directory B. See more by executing man mv
.
This command can be used to rename a file, to do so execute:
mv fileA fileB
mkdir
Modified 2019-09-22 by Andrea Censi
Make new directory. See more by man mkdir
.
rm
Modified 2019-09-22 by Andrea Censi
Remove certain file. rm -r
will also remove directories. More in man rm
.
touch
Modified 2019-09-22 by Andrea Censi
Update the access and modification times of the input file to current time. See more by man touch
.
It can be used to create empty documents, for example:
touch duckie.txt
Will create an empty text file.
Modified 2019-09-22 by Andrea Censi
reboot
Modified 2019-09-22 by Andrea Censi
This command must be executed as root. sudo
required. This will reboot your laptop or Raspberry Pi. See more by man reboot
.
shutdown
Modified 2019-09-22 by Andrea Censi
This command requires sudo
. You can set a countdown to shutdown you machine. More by man shutdown
.
Modified 2019-09-22 by Andrea Censi
cat
Modified 2019-09-22 by Andrea Censi
Cat some file will return you the content. More in man cat
.
tee
Modified 2019-09-22 by Andrea Censi
Read from standard input and write to standard output and files. More on man tee
.
truncate
Modified 2019-09-22 by Andrea Censi
Modified 2019-09-22 by Andrea Censi
fdisk
Modified 2019-09-22 by Andrea Censi
TODO: to write
mount
Modified 2019-09-22 by Andrea Censi
TODO: to write
umount
Modified 2019-09-22 by Andrea Censi
TODO: to write
losetup
Modified 2019-09-22 by Andrea Censi
TODO: to write
gparted
Modified 2019-09-22 by Andrea Censi
TODO: to write
dd
Modified 2019-09-22 by Andrea Censi
TODO: to write
sync
Modified 2019-09-22 by Andrea Censi
TODO: to write
df
Modified 2019-09-22 by Andrea Censi
Modified 2019-09-22 by Andrea Censi
passwd
Modified 2019-09-22 by Andrea Censi
Update password of the current user. Old password needed.
chmod
Modified 2019-09-22 by Andrea Censi
chmod
changes permission to a file or a directory. To make a file executable run:
$ sudo chmod +x FILE
groups
Modified 2019-09-22 by Andrea Censi
TODO: to write
adduser
Modified 2019-09-22 by Andrea Censi
TODO: to write
useradd
Modified 2019-09-22 by Andrea Censi
Modified 2019-09-22 by Andrea Censi
curl
Modified 2019-09-22 by Andrea Censi
wget
Modified 2019-09-22 by Andrea Censi
Modified 2019-09-22 by Andrea Censi
htop
Modified 2019-09-22 by Andrea Censi
You can use htop
to monitor CPU usage.
$ sudo apt install htop
TODO: put screenshot
iotop
Modified 2019-09-22 by Andrea Censi
Install using:
$ sudo apt install iotop
Modified 2019-09-22 by Andrea Censi
hostname
Modified 2019-09-22 by Andrea Censi
TODO: to write
ping
: are you there?Modified 2019-09-22 by Andrea Censi
TODO: to write
ifconfig
Modified 2019-09-22 by Andrea Censi
TODO: to write
$ ifconfig
Modified 2019-09-22 by Andrea Censi
iwconfig
Modified 2019-09-22 by Andrea Censi
iwlist
Modified 2019-09-22 by Andrea Censi
iwlist
is useful to understand the status of the Wifi networks.
For example, to get a list of wifi networks, use:
$ sudo iwlist interface scan | grep SSID
To check whether the interface support 5 GHz channels, use:
$ sudo iwlist interface freq
Example output:
wlx74da38c9caa0 20 channels in total; available frequencies :
Channel 01 : 2.412 GHz
Channel 02 : 2.417 GHz
Channel 03 : 2.422 GHz
Channel 04 : 2.427 GHz
Channel 05 : 2.432 GHz
Channel 06 : 2.437 GHz
Channel 07 : 2.442 GHz
Channel 08 : 2.447 GHz
Channel 09 : 2.452 GHz
Channel 10 : 2.457 GHz
Channel 11 : 2.462 GHz
Channel 36 : 5.18 GHz
Channel 40 : 5.2 GHz
Channel 44 : 5.22 GHz
Channel 48 : 5.24 GHz
Channel 149 : 5.745 GHz
Channel 153 : 5.765 GHz
Channel 157 : 5.785 GHz
Channel 161 : 5.805 GHz
Channel 165 : 5.825 GHz
Current Frequency:2.437 GHz (Channel 6)
Note that in this example only some 5Ghz channels are supported (36, 40, 44, 48, 149, 153, 157, 161, 165); for example, channel 38, 42, 50 are not supported. This means that you need to set up the router not to use those channels.
Modified 2019-09-22 by Andrea Censi
scp
Modified 2019-09-22 by Andrea Censi
The Secure Copy (scp) copies files from different hosts using ssh for data transfer.
Modified 2019-09-22 by Andrea Censi
To download a file named file.txt
which is on hostname
use this command:
laptop $ scp hostname:/path/to/file.txt /path/where/you/whish/.
to download file.txt
to /path/where/you/whish/
. If you want to download in the current directory simply use:
laptop $ scp hostname:/path/to/file.txt .
rsync
Modified 2019-09-22 by Andrea Censi