Linux & the Command Line
In this page
- Disk utilities
- Software management
- Arguments in the command line
- File manipulation
- SHA generation
- bash
1. Disk utilities
Some commands to get information on disk parameters, usage, and what not.
$ sudo hdparm -i /dev/sda # Find hd parameters $ df -h # Disk usage
2. Software management
Some options for the apt series and related commands.
$ sudo apt-get update # Updates the list of applications $ sudo apt-get dist-upgrade # Do the real app update $ dpkg --get-selections # Find installed programs $ sudo apt-get purge indicator-messages # Uninstall plugin for panel pigdin icon
3. Arguments in the command line
Two options to use a file content as command line arguments:
$ <command> $(cat <argument_file>) # sudo apt-get install $(cat args.txt) $ cat <argument_file> | xargs <command> # cat args.txt | xargs sudo apt-get install
4. File manipulation
Convert the file encoding, in particular when it is not compatible with some programs that use utf-8:
$ file -bi <filename> # Find encoding $ iconv -f <enc> -t <new_enc (ex: utf-8)> <file> > <new_file> # Change encoding
Renames, recursively, all files in <rootdir>, and below, so that they only contain lowercase characters. This is taken from this page) and it is not garanteed to work with special characters.
$ find <rootdir> -depth -exec rename 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;
5. SHA generation
Generate sha-1 and sha-256 hashes (note the -n option to avoid including a new line character in the generation of the hash):
$ echo -n "test" | sha1sum | awk '{print $1}' # sha-11 $ echo -n "test" | sha256sum | awk '{print $1}' # sha-256
6. bash
Useful bash commands:
$ bash # Re-initializes the bash shell