User Tools

Site Tools


software:linux

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
software:linux [2014/08/21 09:24] – [APT and packages] Michele Porellisoftware:linux [2021/12/06 10:54] (current) – [Quick HTTP server] Michele Porelli
Line 11: Line 11:
 # apt-get clean ; apt-get update ; exit</code> # apt-get clean ; apt-get update ; exit</code>
   * [[http://www.torino19.org/mike/pool/apt/fixgpgkeys|script]] to fix GPG keys errors   * [[http://www.torino19.org/mike/pool/apt/fixgpgkeys|script]] to fix GPG keys errors
-  * Manual remove of a package +  * Manual remove of a package (last resort!!) 
-  - First try:<code>dpkg -P --force-all nagios-common</code> +  - The cleanest way to remove the package is:<code>dpkg -P --force-all nagios-common</code> 
-  - If still no joy:<code>List the package contents and take a note of this list+  - If the process fails:<code>List the package contents and take a note of this list
 $ dpkg -L nagios-common $ dpkg -L nagios-common
  
Line 27: Line 27:
 to finish up, remove all files you found previously with 'dpkg -L'</code> to finish up, remove all files you found previously with 'dpkg -L'</code>
   * [[http://snipplr.com/view/13856/remove-all-rc-files-as-listed-in-dpkg/| Remove remaining configuration of all packages uninstalled]]   * [[http://snipplr.com/view/13856/remove-all-rc-files-as-listed-in-dpkg/| Remove remaining configuration of all packages uninstalled]]
 +    * <code>apt list | grep 'residual-config'</code>
 +    * <code>sudo aptitude purge ~c</code>
   * [[http://www.linuxcertif.com/man/1/dlocate/|dlocate]] is a really useful software to find which installed package provide a file on your system   * [[http://www.linuxcertif.com/man/1/dlocate/|dlocate]] is a really useful software to find which installed package provide a file on your system
   * [[http://alioth.debian.org/projects/cruft/|cruft]] search for orphans files (not unpacked by dpkg)   * [[http://alioth.debian.org/projects/cruft/|cruft]] search for orphans files (not unpacked by dpkg)
   * [[http://ailoo.net/2009/06/repack-a-deb-archive-with-dpkg-deb/|Repack a .deb]] changing dependencies, provided packages, ecc...   * [[http://ailoo.net/2009/06/repack-a-deb-archive-with-dpkg-deb/|Repack a .deb]] changing dependencies, provided packages, ecc...
   * [[http://kitenet.net/~joey/code/dpkg-repack/|dpkg-repack]] creates a .deb file out of a debian package that has already been installed   * [[http://kitenet.net/~joey/code/dpkg-repack/|dpkg-repack]] creates a .deb file out of a debian package that has already been installed
 +  * [[https://wiki.debian.org/UnattendedUpgrades|Unattended upgrades]] - Automate security upgrades
 ==== Packages outside repositories ==== ==== Packages outside repositories ====
   * [[http://www.skype.com/intl/it/get-skype/on-your-computer/linux/downloading.debian64|Skype 64bit]] for Debian   * [[http://www.skype.com/intl/it/get-skype/on-your-computer/linux/downloading.debian64|Skype 64bit]] for Debian
 ==== How-Tos ==== ==== How-Tos ====
-  * [[software:linux:debianleprimecosedafare|Debian - Le prime cose da fare]] - My guide written for new Debian users (Available only in italian)+  * [[software:linux:debianleprimecosedafare|Debian - Le prime cose da fare]] - My guide written for new Debian users (Available only in italian and really outdated)
   * [[http://guide.debianizzati.org/index.php/Indice_Guide|Guide di Debianizzati.org]] - A lot of guides for Debian (available only in italian)   * [[http://guide.debianizzati.org/index.php/Indice_Guide|Guide di Debianizzati.org]] - A lot of guides for Debian (available only in italian)
   * [[http://netstudent.polito.it/wiki/index.php/HowTo_Debian_Encrypted_Root|Debian encrypted root]] - (Available only in italian)   * [[http://netstudent.polito.it/wiki/index.php/HowTo_Debian_Encrypted_Root|Debian encrypted root]] - (Available only in italian)
Line 42: Line 45:
     nautilus -q     nautilus -q
     Alt-F2 -> nautilus</code>     Alt-F2 -> nautilus</code>
 +  * Fix Debian annoying locales problems: [[http://codetheory.in/fixing-locale-warnings-notices-issues-on-linux-server-or-desktop/|1]], [[https://fruit.je/utf-8|2]], [[http://perlgeek.de/en/article/set-up-a-clean-utf8-environment|3]], [[http://www.linuxquestions.org/questions/blog/bittner-195120/remove-unwanted-locales-on-ubuntu-debian-3281/|4]]
   * Configure PulseAudio: (NOTE: Wheezy is pulseaudio ready, this guide is Debian >=6.x only)   * Configure PulseAudio: (NOTE: Wheezy is pulseaudio ready, this guide is Debian >=6.x only)
     - INSTALL PULSEAUDIO<code># aptitude install pulseaudio pulseaudio-module-gconf     - INSTALL PULSEAUDIO<code># aptitude install pulseaudio pulseaudio-module-gconf
Line 67: Line 71:
 search "ao=alsa" and replace it with "ao=pulse"</code> search "ao=alsa" and replace it with "ao=pulse"</code>
   * To automatically mount NFS shares at boot time put in /etc/default/rcS<code>ASYNCMOUNTNFS="no"</code>   * To automatically mount NFS shares at boot time put in /etc/default/rcS<code>ASYNCMOUNTNFS="no"</code>
 +  * [[https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/Debian%20Buster%20Root%20on%20ZFS.html|Install Debian Buster using ZFS as RootFS]]. If you face problems with the rootfs not being found, you may want to increase the sleep time in initrd [[https://forum.proxmox.com/threads/failed-to-import-rpool-on-bootup-after-system-update.37884/post-273229|as described here]].
 ===== Kernel related ===== ===== Kernel related =====
   * [[http://www.makelinux.net/kernel_map/|Interactive kernel map]]   * [[http://www.makelinux.net/kernel_map/|Interactive kernel map]]
- 
   * [[http://www.linux-tutorial.info/modules.php?name=Howto&pagename=Linux-i386-Boot-Code-HOWTO/makefiles.html|Linux's makefiles]]   * [[http://www.linux-tutorial.info/modules.php?name=Howto&pagename=Linux-i386-Boot-Code-HOWTO/makefiles.html|Linux's makefiles]]
   * [[http://www.codeguru.com/forum/archive/index.php/t-415186.html|Convert vmlinuz to vmlinux]]   * [[http://www.codeguru.com/forum/archive/index.php/t-415186.html|Convert vmlinuz to vmlinux]]
Line 100: Line 103:
  
 ==== Defend your server against DDoS, Bruteforce, ecc.. ==== ==== Defend your server against DDoS, Bruteforce, ecc.. ====
-  * fail2ban+  * [[software:linux:fail2ban|fail2ban]]
   * libapache2-mod-evasive   * libapache2-mod-evasive
   * libapache2-mod-security   * libapache2-mod-security
Line 106: Line 109:
 ==== Quick DHCP server ==== ==== Quick DHCP server ====
 <code>sudo dnsmasq -i eth0 -d --dhcp-range=192.168.89.90,192.168.89.100</code> <code>sudo dnsmasq -i eth0 -d --dhcp-range=192.168.89.90,192.168.89.100</code>
 +==== Quick HTTP server ====
 +<code>python -m SimpleHTTPServer 8000
 +python3 -m http.server 8080</code>
 +
 +==== Quick FTP server ====
 +<code>python -m pyftpdlib -p 2121</code>
 ===== Useful commands ===== ===== Useful commands =====
   * [[http://www.webupd8.org/2009/06/16-top-like-linux-apps-commands.html|List of 16 top-like commands]] to monitor network/system/hdd/ecc...   * [[http://www.webupd8.org/2009/06/16-top-like-linux-apps-commands.html|List of 16 top-like commands]] to monitor network/system/hdd/ecc...
   * [[http://ubuntuforums.org/showthread.php?t=869801&page=2|Change UUID of a NTFS partition]]   * [[http://ubuntuforums.org/showthread.php?t=869801&page=2|Change UUID of a NTFS partition]]
   * [[http://linuxaria.com/howto/7-hidden-features-of-bash?lang=it#|7 bash <del>hidden</del> not well known features]] - (Available only in Italian)   * [[http://linuxaria.com/howto/7-hidden-features-of-bash?lang=it#|7 bash <del>hidden</del> not well known features]] - (Available only in Italian)
 +  * [[http://man7.org/linux/man-pages/man1/fallocate.1.html|fallocate - preallocate or deallocate space to a file (Immediately!)]]
   * Scheduled shutdown/hibernate<code># shutdown -h +X     # X = minutes to wait before shutdown   * Scheduled shutdown/hibernate<code># shutdown -h +X     # X = minutes to wait before shutdown
 # shutdown -h 23:20     # 23:20 = hh.mm, system wait until system clock is 22.30 then shutdown # shutdown -h 23:20     # 23:20 = hh.mm, system wait until system clock is 22.30 then shutdown
Line 125: Line 135:
   * [[http://developer.gnome.org/autostart-spec/|Autostart at login]] - Official specification (works with GNOME/KDE)   * [[http://developer.gnome.org/autostart-spec/|Autostart at login]] - Official specification (works with GNOME/KDE)
   * [[https://groups.google.com/forum/?fromgroups=#!topic/google-labs-picasa-for-linux/5zCxxzAx7Xo|Fix Picasa freezes after opening "Places" tab]]   * [[https://groups.google.com/forum/?fromgroups=#!topic/google-labs-picasa-for-linux/5zCxxzAx7Xo|Fix Picasa freezes after opening "Places" tab]]
-  Guides ([[http://linuxconfig.org/linux-authentication-login-with-usb-device|1]], [[https://mattmole.wordpress.com/2008/04/28/authenticate-using-usb/|2]]) to use an USB drive as login token Consider applying [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=669637|my patch]] to use an SD Card to not waste an USB port :)+ 
 +==== Reverse dynamic proxy ==== 
 +  <code>ssh remoteuser@remotehost -R forwardedsshport:localhost:localsshport -t "ssh -D dynamicproxyport localuser@localhost -p forwardedsshport"</code> 
 + 
 +==== Authenticate with USB/SD device with automatic lock/unlock - libpam-usb ==== 
 +This is based on [[http://linuxconfig.org/linux-authentication-login-with-usb-device|1]], [[https://mattmole.wordpress.com/2008/04/28/authenticate-using-usb/|2]] and some stuffs found on the net. The following steps assumes that your using a Debian based distro with Gnome as DM. 
 +  Install libpam-usb package<code>$ sudo apt-get install libpam-usb</code> 
 +  - Add support for SD cards readers with [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=669637|my patch]] in order to not waste an USB port :) 
 +  - Plug-in your device and create a new token<code>$ sudo pamusb-conf --add-user YOURUSER</code> 
 +  - Add pamusb-agent to your startup applications<code>$ echo "[Desktop Entry] 
 +Name=pamusb-agent 
 +GenericName=PAM USB Auth 
 +Exec=/usr/bin/pamusb-agent 
 +Terminal=false 
 +Categories=Tools 
 +Type=Application 
 +StartupNotify=false 
 +X-GNOME-Autostart-enabled=true" > ~/.config/autostart/pamusb-agent.desktop</code> 
 +  - Change automated actions<code>$ sudo vi /etc/pamusb.conf 
 + 
 +Look for the row containing <user id="YOURUSER"> and append before </user> the following lines 
 +                        <agent event="lock">dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock</agent> 
 + <agent event="unlock">dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.SetActive boolean:false</agent> 
 +</code> 
 +  - Logout/login and see the magic happen :) 
 ==== Fixed (and automatically) mountpoint for external drives ==== ==== Fixed (and automatically) mountpoint for external drives ====
   - Edit your fstab specifying UUID, mountpoint and options (including "auto")   - Edit your fstab specifying UUID, mountpoint and options (including "auto")
Line 139: Line 174:
   - Restart udev   - Restart udev
   - Enjoy automatically mount :)   - Enjoy automatically mount :)
 +==== Make your Gnome 3 terminal transparent ====
 +  - Install Devil's Pie 2<code># apt-get install devilspie2</code>
 +  - Create devilspie2 configuration folder<code>$ mkdir ~/.config/devilspie2</code>
 +  - Paste this devilspie2 script inside a new file<code>$ nano ~/.config/devilspie2/terminal.lua
 +if (get_application_name() == "Terminal") then
 +   set_window_opacity(0.85)
 +   set_window_size(1000, 650)
 +   center()
 +end</code>
 +  - Run devilspie2 at login<code>$ nano ~/.config/autostart/devilspie2.desktop
 +[Desktop Entry]
 +Type=Application
 +Exec=/usr/bin/devilspie2
 +Hidden=false
 +X-GNOME-Autostart-enabled=true
 +Name[en_US]=devilspie2
 +Name=devilspie2
 +Comment[en_US]=devilspie2
 +Comment=devilspie2</code>
 ==== You didn't say the magic word! ==== ==== You didn't say the magic word! ====
 If you are a real hacker you can't imagine something better then [[http://www.youtube.com/watch?v=RfiQYRn7fBg|Jurassic Park login]]! If you are a real hacker you can't imagine something better then [[http://www.youtube.com/watch?v=RfiQYRn7fBg|Jurassic Park login]]!
Line 209: Line 263:
   - Now every 3 login failed the video shows up! It works without xorg too!   - Now every 3 login failed the video shows up! It works without xorg too!
  
 +==== Backup a lot of data from a remote (not directly accessible) VM with minimum overhead ====
 +  - Connect to server<code>$ ssh user@ip_server -L 1900:ip_vm:1900</code>
 +  - Then connect to your VM<code>$ ssh user@ip_vm</code>
 +  - Start the listener<code>$ tar zc * | nc -l 1900</code>
 +  - Open a new terminal and start the receiver<code>nc localhost 1900 | tar zx</code>
 +
 +==== Copy a big amount of data as fast as possible ====
 +  * <code>tar cpf - . | pv | (cd /dst; tar xf -)</code>
 +==== Add a disk to extend a LVM logical volume ====
 +  - Mark your disk/partition as LVM<code># pvcreate /dev/sdX</code>
 +  - Extend the VolumeGroup containing your logical volume<code># vgextend VolGroup00 /dev/sdX</code>
 +  - Extend the logical volume<code># lvextend -l +100%FREE /dev/VolGroup00/LogVol02</code>
 +  - Extend the filesystem<code># resize2fs /dev/VolGroup00/LogVol02</code>
software/linux.1408605851.txt · Last modified: 2014/08/21 09:24 by Michele Porelli