How to generate a random password using the command line.

The shuf command for Linux allows a command-line user to select a given number of random words from a wordlist. [jason@localhost ~]$ shuf -n 8 /usr/share/dict/words amphivasal thoracically U. bluet Dabih thioamid taxiing convictism[jason@localhost ~]$ shuf -n 8 /usr/share/dict/words amphivasal thoracically U. bluet Dabih thioamid taxiing convictism This can be used to generate a word … Read more

Some useful bash shell scripts for the Linux user.

This function will allow your computer to speak. function shellspeak() { mplayer "http://translate.google.com/translate_tts?tl=en&q=$(echo $@ | sed ‘s/\s/+/’)" > /dev/null 2>&1; }function shellspeak() { mplayer "http://translate.google.com/translate_tts?tl=en&q=$(echo $@ | sed ‘s/\s/+/’)" > /dev/null 2>&1; } A script that will change all files in a directory to lowercase filenames. function lowercase() # move filenames to lowercase. { for … Read more

How to send a message to logged on users on your Linux system with a simple command.

The wall command is a perfect way to send a message to all logged on users on a Linux machine. This is used when you shutdown to alert all users that the system will be shutting down. The example below shows me sending the output of the ps command to all users. ubuntu@ip-172-31-20-234:~$ sudo ps … Read more

More useful bash tricks for navigating your filesystem.

Navigating the Linux filesystem is very easy. The cd command is used to move to another directory. But there are other ways too. To navigate back to the last directory you were in, type cd -. This will take you back to where you were before. ubuntu /usr/share $ cd – /home/ubuntuubuntu /usr/share $ cd … Read more

How to change the default shell for new users on your Ubuntu Linux system.

The useradd command is used to add new users on your Linux system. But it can be used for other things too. You may display the defaults for new users. jason-H55-USB3% sudo useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/sh SKEL=/etc/skel CREATE_MAIL_SPOOL=nojason-H55-USB3% sudo useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/sh SKEL=/etc/skel CREATE_MAIL_SPOOL=no Use the -s parameter … Read more

A variant of the shellshock bug that still works with the bash 4.3.11 shell.

This is a variant of the shellshock bug for bash that still works on a patched system. I am using Ubuntu 14.04 and this still works for me. env VAR1=’me() {echo "hello"}\ ‘ /bin/touch /home/$LOGNAME/my.textenv VAR1=’me() {echo "hello"}\ ‘ /bin/touch /home/$LOGNAME/my.text So you can still put arbitrary content after the function definition in a bash … Read more

How to change the shell for a user on a Linux system easily with the usermod command.

I recently created a new user with the adduser command. homer@deusexmachina:~/Documents$ sudo adduser jimkirk Adding user `jimkirk’ … Adding new group `jimkirk’ (1002) … Adding new user `jimkirk’ (1002) with group `jimkirk’ … Creating home directory `/home/jimkirk’ … Copying files from `/etc/skel’ … Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully … Read more

A useful script for gaining information about your Ethernet adapter.

This useful shell script will print information about your Ethernet or Wireless adapter. This is very useful for getting a lot of information at once. #!/bin/sh   DEV="eno16777736"   echo "Showing information for the active network interface: $DEV."   echo -e "-*- \e[1mGet timestamping information for your Ethernet device.\e[0m -*-" echo   ethtool -T $DEV … Read more

Some useful Linux scripts for the desktop Linux user who likes the command line.

There are many useful Linux tips that make the life of a Linux user much easier. One is for the VI or VIM editor. To open a file at a specific line; use this command. homer@deusexmachina ~/Documents/yadex-1.7.901 $ vim src/x11.h +33homer@deusexmachina ~/Documents/yadex-1.7.901 $ vim src/x11.h +33 This will open the file x11.h at line 33. … Read more

How to copy files from one machine to another using SSH and the sftp command.

The sftp command allows a user to retrieve files on a remote machine and save them on their computer. Use this command to access the files: sftp -P 443 [email protected]:/home/homer/Downloads/*.pdf I have my SSH server running on port 443, so I need to specify that port when using this command. I am using Cygwin on … Read more

How to use the touch command to create a file with an arbitrary filename.

The touch command ordinarily does not allow the user to create files with a filename like –rf, but if you want to really annoy someone then you may use this command to create one. homer@debian:~$ touch — ‘–rf ‘homer@debian:~$ touch — ‘–rf ‘ And now you have a file named –rf. -rw-r–r– 1 homer homer … Read more

How to change the default plymouth theme manually on Ubuntu 14.10.

Change the default Plymouth theme on Ubuntu Changing the default plymouth theme on Ubuntu 14.10 is not very difficult. Just type this at the shell prompt. This will set the new theme. root@homer-eME730:~# update-alternatives –install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/ubuntustudio-logo/ubuntustudio-logo.plymouth 100root@homer-eME730:~# update-alternatives –install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/ubuntustudio-logo/ubuntustudio-logo.plymouth 100 Now we need to save our changes. root@homer-eME730:~# update-alternatives –config … Read more

Some useful Linux commands and tricks for the bash shell user.

The boxes utility for Linux allows you to render an ascii text box around text. Below is an example. homer@homer-eME730 19:14:21 ~ $ echo `echo "This is a sentence printed to the terminal."` | boxes /***********************************************/ /* This is a sentence printed to the terminal. */ /***********************************************/homer@homer-eME730 19:14:21 ~ $ echo `echo "This is a … Read more

Useful Macintosh OSX terminal commands to get information about your iMac.

The mount command shows information about your mounted partitions on your machine. iMac305:~ admin$ mount /dev/disk0s2 on / (hfs, local, journaled) devfs on /dev (devfs, local, nobrowse) map -hosts on /net (autofs, nosuid, automounted, nobrowse) map auto_home on /home (autofs, automounted, nobrowse) map -fstab on /Network/Servers (autofs, automounted, nobrowse) /dev/disk0s3 on /Volumes/Scratch (hfs, local, journaled)iMac305:~ … Read more

Using tcpdump to capture packets with a wireless connected computer.

Use this command to capture packets with the tcpdump command. This will output to STDOUT, but you may use redirection to divert it to a text file. [root@deusexmachina homer]# tcpdump -i wlp2s0[root@deusexmachina homer]# tcpdump -i wlp2s0 This is the output that you get when you are capturing packets. This is on my home network, so … Read more

More useful shell tricks for bash. These are very useful tricks for any Linux user.

This sed trick will filter out the unwanted characters and leave only the letters ‘A’. homer@deusexmachina ~ $ echo "###AAA" | sed ‘s/###//gi’ AAAhomer@deusexmachina ~ $ echo "###AAA" | sed ‘s/###//gi’ AAA This is how to re-bind the annoying CAPS-Lock key to Esc. This can give that key a new use. xmodmap -e ‘clear Lock’ … Read more