Linux commands

July 03, 2014

Linux shell commands which are not that easy to remember; at least for me.

Important: This is a private notebook! I am not responsible for any damage caused because someone else than me uses any of the following!!!

sed

Useful one-line scripts for sed: sed.sourceforge.net/sed1line.txt

Cheat sheets

Link: cheatography.com

e. g. Closed-source Debugging with GDB Cheat Sheet by fristle

man pages reloaded

explainshell.com: Write down a command-line to see the help text that matches each argument

Extract many zip files in folders

Example: Extract foo.zip into new folder ./foo/

1
ls *.zip | awk -F '.zip' '{print "unzip \"" $0 "\" -d \"" $1 "\""}' | sh

Find in time range

1
2
3
touch -t 201406041800 /tmp/findfrom
touch -t 201406041900 /tmp/findto
find ~ -newer findfrom ! -newer findto | xargs ls -l

Copy with progress

1
2
rsync -a --progress /source/folder /destination/folder
rsync -a --progress /source/add-slash-for-files-in-folder/ /destination/folder

Add user to group without log off log in

1
2
sudo adduser myusername thenewgroup
exec su -l $USER

My aliases

Edit ~/bash_aliases and activate with . ~/bash_aliases. (The dot . is short for ``)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Alias definitions.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

alias ll="ls -al --block-size=\"'1\""

# MAC OS X commands to copy to/paste from clipboard
# install xsel by 'apt-get install xsel'
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'

alias aptguu='sudo apt-get update && sudo apt-get upgrade'
alias aptgi='sudo apt-get install'
alias aptgr='sudo apt-get remove'
alias aptcs='sudo apt-cache search'
alias aptcp='sudo apt-cache policy'

The apostrophe in the ls alias is very nice and I didn’t figure it out from the man pages. But GNU Coreutils says:

A block size specification preceded by ‘'’ causes output sizes to be displayed with thousands separators. The LC_NUMERIC locale specifies the thousands separator and grouping. For example, in an American English locale, ‘--block-size="'1kB"’ would cause a size of 1234000 bytes to be displayed as ‘1,234’.

That is for ls without block-size:

$ ls -al /bin/bash
-rwxr-xr-x 1 root root 1029624 Nov 13  2014 /bin/bash

And ls with block-size:

$ ls -al --block-size="'1" /bin/bash
-rwxr-xr-x 1 root root 1,029,624 Nov 13  2014 /bin/bash

to be continued…

Ausweiskopien

Sind Ausweiskopien in Deutschland erlaubt oder nicht? Continue reading

Access Jedox H2 Console

Published on March 21, 2016