Single Purpose Terminal Commands (CLI)

  10 years ago

This tutorial section of Single Purpose Terminal Comamnds are intended for complex configurations of linux command tied togeather. Other tutorials give examples of how to use the commands. This tutorial is intended for goal oriented objectives. As it grows it is intended to be catogorized by topic. 

Table of Contents

  1. Searching: Finding and Replacing
  2. File System: Administring Windows Shares
  3. Pulse Audio Loopback Monitor Microphone Input

Resource Gathering

Searching: Find a text match inside a file matching extenion

Use grep to display the matching line for each file in current directory matching the extension *.ext

  • grep searchTerm $(find . -name "*.ext")

Searching: Find all files, then text match each file

Use find to to search for all files matching extension, then for each file run grep. This does not display file name. 

  • find . -name "*.ext" -exec grep searchTerm {} \;


Recursively Grep

Use grep to create its own file listing. Where .ext is the extension of the file.

  • grep -r --include="*.ext" searchTerm


<meta content="text/html; charset=utf-8" http-equiv="content-type" />


Multi segmented downloader, Axel, Accelerates Downloads between multiple connections.

Axel tries to accelerate HTTP/FTP downloading process by using multiple connections for one file. It can use multiple mirrors for a download. Axel has no dependencies and is lightweight, so it might be useful as a wget clone on byte-critical systems.

  • sudo apt-get install axel

Use axel to create 3 connection maxed out at a combined speed of 5242880 bytes/sec, or 5120 kbtyes/sec, or 5 Mbyes/sec, or 8 MBit. (This is way fast for internet, reasonable for 100baseT)

  • axel -n 3 -s 1024000

Use multiple mirrors

axel -n 3 -s 5242880

File System Administration:

Administring Windows Shares

Use /etc/fstab to mount a Windows Domain Network Share (using CIFS, aka samba)

Copy and paiste the following one at a time. This is intended to be ran as a script, this is the reason for the sudo su workaround.

  1. sudo apt-get install dialog -y
  2. sudo su
  3. export windowsUsername=`dialog --stdout --inputbox windowsUsername 20 30 mintUser`;
  4. export windowsPassword=`dialog --stdout --inputbox windowsPassword 20 30 guest`;
  5. export serverHostname=`dialog --stdout --inputbox serverHostname 20 30`;
  6. export shareName=`dialog --stdout --inputbox "shareName" 20 30 Public`;
  7. export credentialsLocation=`dialog --stdout --inputbox "Credentials File Location" 20 30 /root/.creds`;
  8. export mintUsername=`dialog --stdout --inputbox "Linux Mint Username" 20 30 mint`;
  9. dialog --infobox "Making the Credentials File" 20 30;
  10. echo "username=$windowsUsername" > $credentialsLocation;
  11. echo "password=$windowsPassword" >> $credentialsLocation;
  12. dialog --infobox "Making the folders for share" 20 30;
  13. mkdir /home/$mintUsername/Servers;
  14. mkdir /home/$mintUsername/Servers/$shareName;
  15. echo --infobox "Writing to /etc/fstab" 20 30;
  16. echo "//$serverHostname/$shareName /home/$mintUsername/Servers/$shareName cifs rw,credentials=$credentialsLocation,uid=1000 0 0" >> /etc/fstab;
  17. umount /home/$mintUsername/Servers/*
  18. chown -Rv $mintUsername:$mintUsername /home/$mintUsername/Servers;
  19. mount -a

Fix Apache Permissions for Joomla 1.6 or PHP suggested

Find can be used to repair the apache htdocs directory (aka html).

  • chown root:apache -R /var/www/html
  • cd /var/www/html
  • find . -type f -exec chmod 644 {} \;
  • find . -type d -exec chmod 775 {} \;
  • find . -type f -name "configuration.php" -exec chmod 664 {} \;
  • find . -type f -name "*.ini" -exec chmod 664 {} \;
  • find . -type f -name "*.css" -exec chmod 664 {} \;
  • find . -type f -name ".htaccess" -exec chmod 755 {} \;



Pulse Audio Loopback Monitor (hear) Microphone Input.

Tested on Linux Mint 11

Open the Menu >> Preferences >> Sound, Set Hardware Profile to : Analog Sterio Duplex. Set Input Connector: Analog Microphone at Unamplified Volume

Test the settings first, Will only work for this Restart/Session?

  • pactl load-module module-loopback

Write the configuration while execuiting the bourne shell command as root.

  • sudo sh -c ' echo "load-module module-loopback" >>  /etc/pulse/ '
MagicMint 7 years ago

It looks more like a personal scratch pad than a tutorial ;-)

FedorUvarov 10 years ago

freelance writer