r/UnixProTips • • Jul 06 '25

Have you used this distibution sometime?

Post image
9 Upvotes

r/UnixProTips • • Feb 18 '15

'free' and Memory Utilization - a short article I wrote about Unix's free command

Thumbnail blog.chewbonga.com
11 Upvotes

r/UnixProTips • • Feb 07 '15

Use the command "set -o vi" to for vi keybindings on the commandline

23 Upvotes

When typing a command, you can hit "escape" and then use hjkl and vi keys to make edits. Super useful for editing long commands.

Edit: This doesn't work on every shell, but it does work with ash/bash.


r/UnixProTips • • Feb 08 '15

Use ShellCheck to check shell scripts!

24 Upvotes

ShellCheck is a static analysis tool for sh/bash scripts. It detects a wide range of common errors and pitfalls. It is written in Haskell and you can install a local version (it is packaged in Debian/Ubuntu as shellcheck), it should work well with Emacs' flyspell or vim's syntastic.

See also the list of Bash pitfalls: http://mywiki.wooledge.org/BashPitfalls


r/UnixProTips • • Feb 16 '15

Github's collection of dotfiles repos & tutorials

29 Upvotes

I'm one of the maintainers, so I'm a bit biased, but I think that the collection of dotfiles repositories & tutorials at https://dotfiles.github.io/ is a pretty good starting point.


r/UnixProTips • • Feb 11 '15

[bash] Shortcuts For Maximum Productivity

Thumbnail
skorks.com
32 Upvotes

r/UnixProTips • • Aug 03 '24

Fedora 40 how to install video codecs - RPM Fusion tutorial

Thumbnail
youtube.com
7 Upvotes

r/UnixProTips • • Feb 11 '15

Get the difference between the output of any commands

30 Upvotes

diff <(command1) <(command2)

diff <(ls dir1) <(ls dir2)


r/UnixProTips • • Feb 04 '15

Quickly solving Debian (or derivative) "file not found" errors during compilation.

8 Upvotes

If a compilation ever fails because of a missing file, simply install "apt-file" and do

apt-file search "filename"

and install the corresponding package. 99% of the time, this saves the need to troubleshoot the error on forums.

Another tip is to install and use "checkinstall" instead of "make && make install" - that way you can remove the installed package simply with

dpkg -r "package"

EDIT: formatting


r/UnixProTips • • Feb 03 '15

Quick & simple logging macro for bash scripts

7 Upvotes

Mostly just throwing this in here to help out a fledgling subreddit... Fly little subreddit, fly!

Anyway, I use this bit as a quick and simple log macro in a lot of my less robust bash scripts:

LOG="echo ["`basename $0`"] "

Usage:

$LOG"Log this message"
$LOG"And this one"
$LOG"And even this longer one thats also about nothing"

Result:

[script.sh] Log this message
[script.sh] And this one
[script.sh] And even this longer one thats also about nothing

The basename $0 bit returns the filename from the path you called. Then I just put it in brackets and echo that before the message. So calling my/project/bin/script.sh results in [script.sh].

Super simple, probably obvious, but I like that it only takes up one line but is sufficient for just about any small or one-off script. And it's portable!

Anyone use anything similar?


r/UnixProTips • • Feb 04 '15

history, !123 (run item 123 from your history)

6 Upvotes

r/UnixProTips • • Feb 03 '15

Collaboration?

5 Upvotes

Have you considered working with https://twitter.com/climagic ?


r/UnixProTips • • Feb 03 '15

handy hddtemp bash function

5 Upvotes

Once in a while i want to check the temperature of the hdd's which i have installed in my system, so i thought i create a handy bash function for that. :)

hdtemp() {
    i=0
    hdd_dev_list=(
        '/dev/sdc'
        '/dev/sdb'
    )

    for i in ${hdd_dev_list[@]}; do
        echo -e "$i `sudo hddtemp $i | awk {'print $3'}`"
    done
}

r/UnixProTips • • Feb 04 '15

pss, a simple bash function to grep the ps output (colored output)

5 Upvotes

A simple function to quickly grep the output of ps (green colored)

pss() {
    if [ "$1" == "" ]; then
        echo -e "usage: pss NAME\n"
    else
        echo -e "\033[1;32m`ps ax | grep $1 | grep -v grep`\033[0m"
    fi
}

r/UnixProTips • • Feb 05 '15

Check the top 10 commands you use

30 Upvotes

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10


r/UnixProTips • • Feb 05 '15

comm - select or reject lines common to two files

8 Upvotes

If you have two sorted files you can slice on common lines in a few handy ways:

Lines only in file 1: comm -23 file1 file2
Lines only in file 2: comm -13 file1 file2
Lines that appear in both file 1 and file 2: comm -12 file1 file2

r/UnixProTips • • Feb 04 '15

Bash function to extract all archives

9 Upvotes

Use one command to extract them all:

function extract()
{
if [ -z "$1" ]; then
    echo "Usage: extract [FILE]"
else
    if [ -f "$1" ]; then
        case "$1" in
            *.7z) 7z x "$1" ;;
            *.bz2) bunzip2 "$1" ;;
            *.exe) cabextract "$1" ;;
            *.gz) gunzip "$1" ;;
            *.lzma) unlzma "$1" ;;
            *.rar) unrar x -ad "$1" ;;
            *.tar.bz2) tar xvjf "$1" ;;
            *.tar.gz) tar xvzf "$1" ;;
            *.tar) tar xvf "$1" ;;
            *.tar.xz) tar xvJf "$1" ;;
            *.tbz2) tar xvjf "$1" ;;
            *.tgz) tar xvzf "$1" ;;
            *.xz) unxz "$1" ;;
            *.zip) unzip "$1" ;;
            *.Z) uncompress "$1" ;;
            *) echo "extract: '$1' - unknown archive method" ;;
        esac
    else
        echo "'$1' - file does not exist"
    fi
fi
}

r/UnixProTips • • Feb 03 '15

bash function to get your remote ip

7 Upvotes

A simple function to retrieve your current remote ip.

get_ip() {
    page='http://myip.dnsomatic.com'

    which curl > /dev/null 2>&1
    if [ "$?" -eq "0" ]; then
            echo "ip: `curl -s $page`"
    else
            echo -e "curl is not installed, aborting"
    fi
}

r/UnixProTips • • Feb 05 '15

Add space before the command and it won't be saved to your history.

26 Upvotes

r/UnixProTips • • Feb 07 '15

Add a default opening command to bashrc

5 Upvotes

In my bashrc I have :

alias gop='gnome-open'

This allows me to do

gop <file_name>

And it will open with the default program... Perhaps there's a nicer way of doing this, I'm all ears :)


r/UnixProTips • • Feb 08 '15

ls: display file size with thousands separator

14 Upvotes

The file or block size in ls and df, du, ... can become quite unreadable:

$ ls -l dat*
-rw-r--r-- 1 fritz fritz 747571797 Jan 23 03:13 dat1
-rw-r--r-- 1 fritz fritz 769838509 Jan 23 20:57 dat2
-rw-r--r-- 1 fritz fritz 736028643 Jan 23 21:34 dat3
-rw-r--r-- 1 fritz fritz 733700320 Jan 23 21:39 dat4
-rw-r--r-- 1 fritz fritz 710093303 Jan 23 21:56 dat5
-rw-r--r-- 1 fritz fritz 752512339 Jan 23 23:15 dat6

The GNU coreutils support showing thousands separator by adding a ' to the block size.

$ ls -l --block-size=\'1 dat*
-rw-r--r-- 1 fritz fritz 747,571,797 Jan 23 03:13 dat1
-rw-r--r-- 1 fritz fritz 769,838,509 Jan 23 20:57 dat2
-rw-r--r-- 1 fritz fritz 736,028,643 Jan 23 21:34 dat3
-rw-r--r-- 1 fritz fritz 733,700,320 Jan 23 21:39 dat4
-rw-r--r-- 1 fritz fritz 710,093,303 Jan 23 21:56 dat5
-rw-r--r-- 1 fritz fritz 752,512,339 Jan 23 23:15 dat6

The actual separator depends on the LC_NUMERIC locale. The block size can also be specified by setting either the tool specific LS_BLOCK_SIZE or the general BLOCK_SIZE environment variables. Alternatively an alias can be used:

alias ls="ls --block-size=\'1 --color=auto"

(edit: With --color=auto the output will use colors on terminal that support it. Thanks to /u/pie-n)

See the (coreutils) Block size info page for more information.


I'd also like to take the opportunity to point people interested in Linux programming to /r/linux_programming


r/UnixProTips • • Feb 05 '15

Change Title of Terminal Programs

4 Upvotes

Works on at least some X terminals.

function title () {
    [[ "${TERM}" != 'linux' ]] && printf "\033]0;%s\007\n" "$@"
}

Should work in bash, zsh, etc.


r/UnixProTips • • Feb 05 '15

Shift-ctrl-u for Unicode entry.

3 Upvotes

I think this only works in Linux (and not in the console) but it's brilliant. Try it out now in the comment field. When you're entering text, just hit shift-ctrl-u, and you will see an underlined 'u'. Then you enter the hex code for any Unicode character and it will appear.


r/UnixProTips • • Feb 03 '15

Hello!

11 Upvotes

Well hopefully this place gets some subscribers and I'm not doing all this for nothing. :-)

The idea is simple. Reddit has Unix pro tips everywhere! Instead of constantly saving threads or using the search function to try to find that one super awesome tip you once found.. we have a place for them now. Here! So post your own ones or other ones you have found and hopefully this place will grow and serve a purpose.

I am open to suggestions, criticism and help. Thanks. :-)

edit: Might be a good idea to also include a header of some sort if your tip is specifically related to Linux/BSD or one of the sub flavours of either.