Configure PS1 Variable
Reverse SSH
Using ZIP
zip
is a simple command to archive and compress files
Help:
Compression level
-9 : number 9 is the best compression level, use 0 for no compression. The highest compression level is the slowest. 6 is a good average.
zip -9 zipfile.zip fileotadd.file
https://www.tecmint.com/run-repeat-linux-command-every-x-seconds/
add files to archives
zip add -9 zipfile.zip fileotadd.file
Add new file and update existing one if needed
update (-u)
Update existing entries if newer on the file system and add new files. If the archive does not exist issue warning then create a new archive.
zip -u -9 existingzipfile.zip listfileotadd.*
Using multi thread to compress
You need additional tool like pigz
https://www.tecmint.com/compress-files-faster-in-linux/
option (-k) to retain original file and (-9) for best compression
exemple:
tar -I "pigz -k -9" -cf dir1.tar.gz dir1
Packages indispensables
apt install openssh-server
apt install sshfs
apt install joe
Petits scripts indispensables
Le script d'UPDATE du système:
#!/bin/bash
echo "**"
echo "*****************************"
echo "** Doing the UPDATE"
echo "*****************************"
apt --yes update
echo "**"
echo "*****************************"
echo "** Doing the UPGRADE"
echo "*****************************"
apt --yes upgrade
echo "**"
echo "*****************************"
echo "** Doing the UPGRADE of the Distro"
echo "*****************************"
apt --yes dist-upgrade
echo "**"
echo "*****************************"
echo "** Cleaning The system"
echo "*****************************"
apt --yes autoclean
apt --yes autoremove
echo "Nightly Updates Successful: $(date)">> /tmp/updatingsystem.log
Script pour créer un point de montage et monter le repertoire distant sur le serveur correspondant à l'utilisateur connecté. Montage crypté permettant d'obtenir un cloud privé et sécurisé.
#!/bin/bash
if [ ! -d "$HOME"/EsoaCloud ];
then
mkdir "$HOME"/EsoaCloud
fi
sshfs 192.168.0.2:/home/"$USER" "$HOME"/EsoaCloud
Executing script in background and exit terminal
To avoid exit signals propagating to child processes of the terminal and shell, run the command with nohup, i.e.:
nohup cmd &
Planification de tâches : CRONTAB
tout d'abord un petit script bien pratique ici surtout le script de mise à jour à base de apt-get
ensuite il faut utiliser les instructions cron
tout d'abord éditer les lignes de cron:
crontab -e
Puis connaitre la syntaxe: http://www.openjs.com/scripts/jslibrary/demos/crontab.php
La syntaxe de cronteb est la suivante:
minute (m), hour (h), day of month (dom), month (mon), day of week (dow)
Ce qui peut donner pour une exécution de l'instruction update
une fois par semaine à 3h00 am:
0 3 * * 1 update
How to run and repeat command line
https://www.tecmint.com/run-repeat-linux-command-every-x-seconds/
The next logical question is – how to change the execution interval. For that purpose, you can use the -n option, that specifies the interval with which the command will be executed. This interval is specified in seconds. So let’s say you want to run your script.sh file every 10 seconds, you can do it like this:
# watch -n 10 script.sh
Note that if you run the command like shown above, you will need to cd to the directory (learn Learn 15 cd Command Examples) where the script is located or otherwise specify the full path to that script.
Other useful options of watch command are:
- b – creates a beep sound if the exit of the command is non-zero.
- c – Interprets ANSI color sequences.
- d – highlights the changes in the command output.
Monitor Progress of Copy Command
In Linux, while copying files from one location to other using cp
command, the progress of data is not shown, to see the progress of data being copied, you can use the watch command along with du -s
command to check the disk usage in real time.
# cp ubuntu-15.10-desktop-amd64.iso /home/tecmint/ &
# watch -n 0.1 du -s /home/tecmint/ubuntu-15.10-desktop-amd64.iso
If you think that the above process is too complicated to achieve, then I suggest you to go for Advance copy command, which shows progress of data while copying.
Date update including BIOS
Sometime with modern system there is a drift between the hardware clock and the system clock due to mismatch local time setup. But you need to get the right time for file synchronization. It is important on a desktop computer and moreover on a server and on the system when you are using unison and so on.
First set the good date
sudo date MMDDhhmm
then synchronize hardware clock and the system time.
first copy HW clock to system time :
sudo hwclock --hctosys
https://www.tecmint.com/run-repeat-linux-command-every-x-seconds/
Then copy the System time to HW Clock:
sudo hwclock --systohc
to see the HW CLock:
sudo hwclock --show
User Administration : Xubuntu
the application is /usr/bin/users-admin