Posted: . At: 9:29 PM. This was 10 years ago. Post ID: 7180
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

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'
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' -e 'keycode 0x42 = Escape' &

Here is how to print the architecture of your Linux installation.

homer@deusexmachina ~ $ dpkg --print-architecture
amd64

How to test disk writing speed with the Linux command line.

homer@deusexmachina ~ $ dd if=/dev/zero of=/tmp/output.img bs=8k count=256k conv=fdatasync; rm -rf /tmp/output.img
262144+0 records in
262144+0 records out
2147483648 bytes (2.1 GB) copied, 19.4116 s, 111 MB/s

Generate a random password using /dev/urandom.

╭──(john㉿DESKTOP-PF01IEE)-[~]
╰───────────────────────────╾┋ sudo cat /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c${1:-24}; echo;
ipwwJd0NwDAJ2Uby2bMoSmgZ

Show all tcp4 listening ports.

homer@deusexmachina ~ $ netstat -lnt4 | awk '{print $4}' | cut -f2 -d: | grep -o '[0-9]*'
443
445
139
51413
53
53
631

Get information about your user.

homer@deusexmachina ~ $ finger homer
Login: homer          			Name: John Cartwright
Directory: /home/homer              	Shell: /bin/bash
On since Mon Apr 21 14:14 (EST) on tty8 from :0
    7 hours 13 minutes idle
On since Mon Apr 21 18:48 (EST) on pts/0 from :0.0
No mail.
Plan:
DOS: n., A small annoying boot virus that causes random spontaneous system
     crashes, usually just before saving a massive project.  Easily cured by
     UNIX.  See also MS-DOS, IBM-DOS, DR-DOS.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.