Basics

Write in a file w/ a single command:

single line:

echo "hello world" > file  # This override the content
echo "hello world 2" >> file  # This concatenate

Multiple lines:

cat <<EOF >file
bla bla
...
bla bla
EOF

Create Desktop shortcut

For Scripts/Programs:

cat <<EOF >~/Desktop/my_shortcut.desktop
[Desktop Entry]
Type=Application
Name=nom du programme
GenericName=nom générique
Comment=commentaire/description du programme
Icon=icône du programme #il peut s'agir d'un chemin, ou alors du nom d'une icône contenue dans votre thème d'icônes
Exec=commande qui permettrait d'ouvrir le programme par le terminal
Terminal=false  #ouvrir ou non un terminal lors de l'exécution du programme (false ou true)
StartupNotify=false  #notification de démarrage ou non (false ou true)
Categories=catégories du programme  #Exemple: Categories=Application;Game;ArcadeGame;
EOF

You can also look at existing shortcuts by doing: ls -l /usr/share/applications/

User specific shortcuts for app menu are in ~/.local/share/applications

For file/folder shortcut:

ln -s original.txt ~//shortcut.txt

Scheduling tasks

(Option 1) Create a service with auto execution at startup:

sudo sh -c 'cat <<EOF >/etc/systemd/system/my_service.service
[Unit]
Description=My Script

[Service]
ExecStart=/home/test/my_script.sh

[Install]
WantedBy=multi-user.target
EOF'

 # Enables the service at startup and start it now

(Option 2): Schedule tasks with crontab:

Crontab is more versatile, you can schedule very minute, hour, at reboot, whatever you want, see https://crontab.guru/ for help.

Here are the 2 most usedul crontab commands:

crontab -l  # List Current cron jobs
crontab -e  # Edit jobs

Here is 2 ways of scheduling tasks at reboot, if your task is complex, prefer shell script:

@reboot [path to command] [argument1] [argument2] … [argument n]
@reboot [part to shell script]

Zip & Unzip Using tar

Zip

tar -czvf path/to/target.tar.gz path/to/dir

Unzip

tar -xvf path/to/archive.tar.gz

Last updated