
This page will cover a wide range of tips and tricks regarding Linux devOps administration.
Some Links:
Bash: curl Command Tips, Methods and Usage Information – Bash curl information resource page
Working With The Linux Files System – Tips & Tricks when working with Files & Directories in Linux
Working with Linux Users , Groups and Permissions– Use Cases for ‘adduser’ & ‘useradd’
External Resource Links
40 Linux Server Hardening Security Tips [2017 edition]
How to Change Systemd Boot Target on Linux
How to Check Hardware Information on Linux Using Command Line Need to make a similar list like this one to put on blog.
Helpful alias’s
Neat little script to show directory and file permissions using numeric notation
The following snippet was found at: Can the Unix list command ‘ls’ output numerical chmod permissions?
alias cls="ls -lha --color=always -F --group-directories-first |awk '{k=0;s=0;for(i=0;i<=8;i++){;k+=((substr(\$1,i+2,1)~/[rwxst]/)*2^(8-i));};j=4;for(i=4;i<=10;i+=3){;s+=((substr(\$1,i,1)~/[stST]/)*j);j/=2;};if(k){;printf(\"%0o%0o \",s,k);};print;}'"
Working with Remote Directories/Folders:
A while ago I has issues mounting a folder on a file server I was trying to backup because it needed to be updated & I really just wanted to do a fresh install.
Well after a bit of searching, turned out that the mount command was defaulting to a newer version of CIFS than my server had. I just had to explicitly set the version to 1.0 in the command line options and I was on my way.
I got the tip from the follolwing page: 16.04 CIFS host is down, but they are not - AskUbuntu.com
Package Managers -
Check apt Package Version
This command tip will return version information on a given package. This command will display the current version of a package that's installed or the version number that's available to install from the apt repository in the event that the package isn't currently installed.
This comes in handy when your trying to decide if you want to install software package trough apt or if you need to compile from source to get a more up-to-date version.
From what I've seen and read on-line, Ubuntu is famous for having old versions of packages littered throughout the apt repository. Knowing this, it's probably a good idea to check the version available instead of installing it and realizing after the fact that it's outdated software that may or maynot have broken functionality.
Here is a format of the command syntax and an example command:
apt-cache policy unison
How to install Debian (.dpkg) packages manually.
- Get the version number of an installed package:
dpkg -s <packagename> | grep '^Version:'
Found this tip at:
How can I find the version number of an installed package via dpkg
The results of 'dpkg --list' contain letter codes that I had a hard time looking up. I did find a snippet in a book (The Debian System: Concepts and Techniques) with a table. Below is my version of that table:
p..purge.i.installed
Letter | State |
---|---|
u.. | *unknown |
i.. | install |
r.. | deinstall |
p.. | purge |
h.. | hold |
.n. | not-installed |
.i. | installed |
.c. | config-files |
.u. | unpacked |
.f. | half-configured |
.h. | half-installed |
..h | *hold |
..r | reinst-required |
..x | reinst-required & *hold |
... | ok (empty third column) |
Notes: Package states and their mappings to single letters. The dots identify the column in which the letter may be seen in the dpkg --list output. States prepended with an asterisk are not states defined by the package management system but rather emerge out of other states.
Echo using sudo
SO I needed to create a file with just one line of text. I though instead of firing up vim, I would just echo the file and send the output to a file instead of the tty.
Well, once again, nothing simple is ever simple. I fortunatly found a page by a developer that seems as fed up with these constant time wasting hurdles.
Basically the command:
sudo echo "some_setting=1234567890" > /etc/write-to-file-needs-root-privledges.conf
Yup, this fails with permission denied, but doing it this way works:
sudo sh -c 'echo "some_setting=1234567890" > /etc/write-to-file-needs-root-privledges.conf
The above command using 'sudo sh -c' does the trick. Just don't forget the single quote around the whole echo command like I did the first time I tried it.
This tip was found at: "Sudo echo: does not work together in Ubuntu (another "waste of time issue") | Oracle Petr Dvorak Blog
End of page Paragraph text to prevent pre-formatted from fuckin shit up