Occasionally I type a password or other sensitive information into a shell prompt. Using bash history, the command can be removed.
# say we start with an empty bash command history
bash-3.2$ history
1 history
# enter a command that requires a password
bash-3.2$ sudo rm -i some_file
Password:
# accidentally ^C and type your password
# into the prompt and hit enter
bash-3.2$ secret_password
bash: secret_password: command not found
# your password is now there for all to
# see in your bash history
bash-3.2$ history
1 history
2 sudo rm -i some_file
3 secret_password
4 history
# first option to fix it, delete the numbered entry from
# history and write to your ~/.bash_history file
bash-3.2$ history -d 3
bash-3.2$ history -w
# entry 3 will be removed entirely from your command history
bash-3.2$ history
1 history
2 sudo rm -i some_file
3 history
4 history -d 3
5 history -w
6 history
# the second option is to clear the entire history
# and write the changes to disk
bash-3.2$ history -c
bash-3.2$ history -w
# it's now pretty obvious that your history has been
# scrubbed clean, but at least your password is history!
bash-3.2$ history
1 history -w
2 history
I► Dans cet article, nous allons aborder les commandes d’administration Linux avancé :
=> mkfifo et script permettent d’initialiser un fichier de type pipe et de récupérer à distance les commandes saisies – exemple :
Un user saisit mkfifo NOmDuFichier (tube), puis démarre le script pour enregistrer les commandes dans ce tube : script -f tube
Un second user (par SSH ou en local) saisit cat tube : le script se met en marche , tout ce qui est saisi par le 1er user est visualisé par le second user :
Le premier user peut mettre fin au scripr en saisissant CTRL+D
=> logger permet d’écrire directement dans le fichier de log principal :
=> Write permet d’écrire directement sur le terminal d’un utilisateur connecté :
=> WALL permet d’écrire sur tous les terminaux ouverts
To make the configuration of iptables persistent on a Debian-based system
Background
The iptables and ip6tables commands can be used to instruct Linux to perform functions such as firewalling and network address translation, however the configuration that they create is non-persistent so is lost whenever the machine is rebooted. For most practical applications this is not the desired behaviour, so some means is needed to reinstate the configuration at boot time.
For security, the iptables configuration should be applied at an early stage of the bootstrap process: preferably before any network interfaces are brought up, and certainly before any network services are started or routing is enabled. If this is not done then there will be a window of vulnerability during which the machine is remotely accessible but not firewalled.
Scenario
Suppose you have a machine that you wish to protect using a firewall. You have written iptables and ip6tables rulesets, and wish to install them so that they will remain active if the machine is rebooted.
Shell – Provides an interface between the user and the kernel.
Terminal emulator – The xterm program is a terminal emulator for the X Window System. It allows user to enter commands and display back their results on screen.
Linux Desktop and Windows Manager – Linux desktop is collection of various software apps. It includes the file manger, the windows manager, the Terminal emulator and much more. KDE and Gnome are two examples of the complete desktop environment in Linux.
Login
User can login locally into the console when in runlevel # 3 or graphically when in runlevel # 5 (the level numbers may differ depending on the distribution). In both cases you need to provide username and password. Bash uses the following initialization and start-up files:
/etc/profile – The systemwide initialization file, executed for login shells.
/etc/bash.bashrc – The systemwide per-interactive-shell startup file. This is a non-standard file which may not exist on your distribution. Even if it exists, it will not be sourced unless it is done explicitly in another start-up file.
/etc/bash.logout – The systemwide login shell cleanup file, executed when a login shell exits.
$HOME/.bash_profile – The personal initialization file, executed for login shells.
$HOME/.bashrc – The individual per-interactive-shell startup file.
$HOME/.bash_logout – The individual login shell cleanup file, executed when a login shell exits.
Script of commands executed at login to set up environment. For example, setup JAVA_HOME path.
Login Shell
Login shells are first shell started when you log in to the system. Login shells set environment which is exported to non-login shells. Login shell calls the following when a user logs in:
/etc/profile runs first when a user logs in runlevel # 3 (the level numbers may differ depending on the distribution).