Linux stuff

12 thoughts
last posted Feb. 5, 2016, 10:37 a.m.
0
get stream as: markdown or atom
0

Selecting and killing a process in htop can be difficult because the order of the processes constantly shift. Press F to let the cursor follow the currently selected process.

0

To make an alias with fish shell create a new function. Avoid recursion by using the command command:

function ls
    command ls -l
end
0

Kill multiple processes with htop:

  • Press F4 and filter for the processes
  • For each process press Space to mark it
  • Press F9 and select a signal to kill all marked processes
0

Just learned about pkill. pkill allows to send signals to processes by specifiying the process name:

pkill -9 firefox

Here I am feeling dump that I used things like this for the last couple of years:

 ps ax | grep firefox | awk '{print $2}' | xargs kill -9
0

JSON hard to read? Try beautifying it with:

python -m json.tool multiproject.json

Note: This also seems to validate the JSON.

0

Just a quick one because I need this all the time but I keep forgetting it: How to append the current date to a filename.

touch abcd_`date +%F`
ls abcd*
> abcd_2015-09-17

or if you are using fish:

touch abcd_(date +%F)
0

Mysql

 select * from token\G

instead of

 select * from token;

will display the the columns as rows below each record. This can avoid line breaks in the output and make it easier to read.

0

SSL

Get information about a SSL certificate:

openssl x509 -in test.crt -text -noout
0

How to copy a vagrant image to another machine

Copy the ssh key from ~/.vagrant.d/insecure_private_key and append it to the same file on the other machine to be able to log into the machine later.

Next:

vagrant package --base vm-name --output /path/to/mybox.box

Copy file to other machine. Then do:

vagrant init vm-name /path/to/mybox.box
vagrant up

Source: http://stackoverflow.com/questions/19094024/is-there-any-way-to-clone-a-vagrant-box-that-is-already-installed

0

To copy files to the home directory using scp you can use the shortcut ./

scp file.zip  user1@123.123.123.123:./
0

Multiple architectures on Ubuntu

List current main architecture:

> dpkg --print-architecture
amd64

List other architectures that are allowed on this system:

> dpkg --print-foreign-architectures
i386

Modify non-main architectures:

sudo dpkg --add-architecture test
sudo dpkg --remove-architecture test

Specifying the architecture when installing packages:

sudo apt-get install libsdl-image1.2:i386

Foreign architectures will be installed in separate directories. E.g.: /usr/lib/i386-linux-gnu/.

Show all packages with a foreign architecture:

dpkg -l | grep :i386

More info: https://wiki.debian.org/Multiarch/HOWTO

0

Cool tip: When typing in a command in a urxvt you can press shift + mouse click anywhere on the current line to move the cursor.

Very useful when fixing a typo in a long command.

Child Streams