Here are some useful Linux commands that we use from time to time

 

Ø Turn on a VPN connection (e.g., VPN1) via a Linux terminal

sudo nmcli con up id 'VPN1' --ask

Ø Check the internet connection status of a VPN (e.g., VPN1)

sudo nmcli con up id 'VPN1' --ask

Ø Add a new user

sudo adduser username

Ø Run a command after a while. For example, the following executes the ‘ls’ command after 1 hour

sleep  1h  &&   ls

Ø Add a user to Sudoers or Sudo Group

sudo adduser username sudo

Ø Kill all processes of a user

killall5    -9

Ø Delete a user, its  home directory and mail spool

userdel   -r   username

Ø List all existing users

cat   /etc/passwd

Ø Enable SSH on Ubuntu

sudo apt update

 

sudo apt install openssh-server

Ø Getting the Size of Home subdirectories

sudo  du  -sh   /home/*

Ø A solution to the following error

/lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found

 

sudo apt-get install libgfortran3

 

Please note that libgfortran3 is no longer supported in Ubuntu 20.04. It depends on an older version of gcc which is no longer maintained in this version of the distribution. If you have to use libgfortran3, you can just copy a libgfortran.so.3 in /usr/lib/x86_64-linux-gnu/ from a machine with Ubuntu 18.

 

sudo su

 

cd /usr/lib/x86_64-linux-gnu

 

scp -r mehdi@172.16.13.224:/usr/lib/x86_64-linux-gnu/libgfortran.so.3 .

 

Ø Pause or resume a process

Find the job ID of the process that you wish to pause. You can accomplish this by using the top or ps commands. Execute the following command to pause the process with a job ID of 20419.

 

 sudo kill -STOP 20419

Execute the following command to resume the paused process.

 

sudo kill -CONT 20419

 

Ø Make a python script binary

You can compile your Python script into a binary file using a Python to binary compiler such as PyInstaller.

1.     Update your pip package

python3 -m pip install --upgrade pip

 

2.     Install PyInstaller

 

/usr/bin/pip3 install pyinstaller

3.     Compile your script into a binary file by running the following command:

 

pyinstaller your_script.py

 

This will generate a binary file in the dist folder.

 

University of Kurdistan, Sanandaj logo

Department of Chemistry, Faculty of Science, University of Kurdistan