Get nice system information on Macintosh OS with the command line.

Get information about apps installed on your Macintosh PC with the lsappinfo command. Use grep as shown below to find out information about a certain app, i.e Firefox in this case. deusexmachina:~ jason$ lsappinfo | grep Firefox 24) "Firefox" ASN:0x0-0x2a02a: bundle path="/Applications/Firefox.app" executable path="/Applications/Firefox.app/Contents/MacOS/firefox" 26) "FirefoxCP WebExtensions" ASN:0x0-0x2c02c: bundle path="/Applications/Firefox.app/Contents/MacOS/plugin-container.app" executable path="/Applications/Firefox.app/Contents/MacOS/plugin-container.app/Contents/MacOS/plugin-container" parentASN="Firefox" ASN:0x0-0x2a02a: (inferred) … Read more

How to use Google search in a web browser. This is a bash styled shell for Google searches.

Check this website out: http://goosh.org/. This website allows you to perform Google searches using a command line like bash. Just type a search query at the command line and the results will be displayed to STDOUT. Here is an example: [email protected]:/web> linux shell 1) Linux Shell Scripting Tutorial – A Beginner’s handbook – FreeOS.com Table … Read more

Very nice bash PS1 prompts.

A complex, but very useful bash shell prompt. PS1=$( sep=$'\xC2\xBB' # UTF-8 U+00BB red=$(tput setaf 1) green=$(tput setaf 2) yellow=$(tput setaf 3) blue=$(tput setaf 4) cyan=$(tput setaf 5) bold=$(tput bold) reset=$(tput sgr0) [[ $EUID -eq 0 ]] && user=$red || user=$green echo "\[$user\]\u@\h\[$reset\] \[$blue$bold\]$sep\[$reset\] \[$yellow\]\W\[$reset\] \[$blue$bold\]$sep\[$reset\] \[$user\]\$\[$reset\] ") Gives the user a prompt that looks … Read more

how to generate long random numbers with the Linux command line.

This simple command prints out a long random number string from /dev/urandom. jason@Yog-Sothoth » img » $ tr -dc "[:digit:]" < /dev/urandom | head -c 64 ; echo 9958048462925775253231939134565711861924198983498274782350446110 Do it this way to remove the newline after the output. This would be good for use in a script. jason@Yog-Sothoth » img » $ tr … Read more

How to add a lecture that appears every time sudo is run.

To add a lecture that appears when sudo is run to remind a user to be careful, just run the sudo visudo command and add these two lines to the /etc/sudoers file. Defaults lecture="always" Defaults lecture_file="/root/lecture"Defaults lecture="always" Defaults lecture_file="/root/lecture" Save the file and then add this text to the /root/lecture file. root@Yog-Sothoth:~# cat lecture 1) … Read more

How to list files with ls that start with letters in the filename and then have numbers.

This is how to list some filenames that start with letters and have some numbers in the filenames. This is a very useful Linux trick. jason@Yog-Sothoth » ~ » $ ls -l [A-Z]*[0-9]*.wav -rw-rw-r– 1 jason jason 4399528 Oct 25 2017 gqrx_20171024_232212_33050000.wav -rw-rw-r– 1 jason jason 2378004 Oct 29 2017 gqrx_20171029_001507_126954900.wav -rw-rw-r– 1 jason jason … Read more

How to have a custom bash prompt that changes when you are in a certain folder.

This is how to create a custom bash prompt that will change if the user is in a certain folder, but is standard anywhere else. PS1="┌─╼ \$(if [[ \$PWD/ = \$HOME/anime/* ]]; then \ echo \"\[\e[1;35m\](\[\e[0;35m\] •\[\e[1;35m\]^ ω ^) \[\e[1;34m\]\$(pwd | sed ‘s|’$HOME/anime/’|アニメ |; s|’$HOME/anime’|アニメ |’)\[\e[0m\]\" \ ; else \ echo \"\[\e[0;35m\]\u\[\e[1;36m\]::\[\e[0;32m\]\h \[\e[1;34m\]\w\[\e[0m\]\" \ ; … Read more

Another way to get only interface names from a Linux machine.

How to return only interface names when listing all installed network interfaces in a Linux box. jason@jason-Lenovo-H50-55:~/Documents$ ip link | grep -Po "(?<=^\d: |^\d\d:)[^:]+(?=:)" lo eth0 wlan0jason@jason-Lenovo-H50-55:~/Documents$ ip link | grep -Po "(?<=^\d: |^\d\d:)[^:]+(?=:)" lo eth0 wlan0 This is very useful to get a listing of all networking interfaces for use in a script. Do … Read more

How to get WIFI information with the command line.

It is very easy to get information about wireless networks with the command line. This example uses iwlist to view the information we need. jason@jason-Lenovo-H50-55:~$ sudo iwlist wlan0 scan | grep ESSID ESSID:"OPTUS58FFG69" ESSID:"TelstraD22F23" ESSID:"OPTUS58FFG69" ESSID:"TelstraD22F23" ESSID:"OPTUS_B8E926"jason@jason-Lenovo-H50-55:~$ sudo iwlist wlan0 scan | grep ESSID ESSID:"OPTUS58FFG69" ESSID:"TelstraD22F23" ESSID:"OPTUS58FFG69" ESSID:"TelstraD22F23" ESSID:"OPTUS_B8E926" This is very good for listing … Read more

How to create a loopback filesystem easily in your home folder. Good for storing files or creating a swapfile.

It is very easy to create a loopback filesystem in your home directory. This can be used to store files, or can be enabled as a swap partition. Firstly, run this command to create a blank file-system image. This will be 524 megabytes. jason@Yog-Sothoth:~/Documents$ dd if=/dev/zero of=myimage.img bs=1024 count=524288jason@Yog-Sothoth:~/Documents$ dd if=/dev/zero of=myimage.img bs=1024 count=524288 Now … Read more

Search your Linux machine for information about a certain package.

To find information about a certain package on a Linux machine, the man command is very useful, but it does not show all man pages that could contain valuable information. The apropos command is what is required to find all pertinent information. This example below shows how to use this command to find all manual … Read more

Get a randomly generated bash shell prompt and some other tricks for the Linux shell.

A nice shell prompt that is randomly generated each time it appears. Working version. PS1="\[\e[1;31m\]$(shuf -n 1 /usr/share/dict/words)\[\e[m\]@\[\e[1;35m\]$(shuf -n 1 /usr/share/dict/words)\[\e[m\]\$ "PS1="\[\e[1;31m\]$(shuf -n 1 /usr/share/dict/words)\[\e[m\]@\[\e[1;35m\]$(shuf -n 1 /usr/share/dict/words)\[\e[m\]\$ " Select a random word from a textfile with bash. ubuntu ~ $ shuf -n 1 /usr/share/dict/words pluckedubuntu ~ $ shuf -n 1 /usr/share/dict/words plucked Select a … Read more

Useful Linux/UNIX commands.

Using wild-cards to display various files in a folder with ls. I recently needed to check whether certain files were in the /usr/lib folder and I used the ls command to do this. to find all files related to the Perl programming language in the /usr/lib directory. ubuntu ~ $ ls /usr/lib/*perl* /usr/lib/libperl.so.5.18 /usr/lib/libperl.so.5.18.2   … Read more

Deleting files on your Linux machine that have strange names. And how to use wildcards on the shell.

I ran a Perl script on my system that created a bunch of files on my computer named as shown below. I could have typed rm -f A* but that could have deleted other files that have a capital “A” as the first letter of the filename. That is where wildcards come into play. I … Read more

How to get information about a video file with the Linux command line.

The Linux command line may be used to get information about a video file easily. Here is an example. Getting the video resolution with a simple command. jason@jason-desktop:~/Videos$ ffprobe -v quiet -print_format json -show_format -show_streams burnout-in-a-town-street.mp4 | grep coded "coded_width": 400, "coded_height": 224,jason@jason-desktop:~/Videos$ ffprobe -v quiet -print_format json -show_format -show_streams burnout-in-a-town-street.mp4 | grep coded "coded_width": … Read more

How to use the sed command to filter text files in Linux and other useful shell tricks for the Linux command line.

Using sed to filter a text file and change a specific character for another. In this case the ” character becomes the ‘ character using the magic of the sed command. Since I am using a character the shell also uses I have to escape it out so the command will work. This can make … Read more

How to create a bash alias that can take arguments.

This bash alias will take a directory name or path as an argument. alias goto=’cd $1’alias goto=’cd $1′ This is an example of how this alias works. jason@jason-desktop:~$ goto /usr/share jason@jason-desktop:/usr/share$jason@jason-desktop:~$ goto /usr/share jason@jason-desktop:/usr/share$ This is a very neat bash trick. This might not work if the directory name uses spaces though. Generate a very … Read more