Dragging a file into your terminal pastes the file path
When you drag a file from a Nautilus window into a terminal window, the file's path will be pasted into the terminal. This also works with multiple files.
Related cards:
Line wrap text from a Ubuntu Linux terminal
You can use fold
:
fold -sw 60
You can now paste your texts. fold
will echo them back, word-wrapped after 60 columns. Exit with Ctrl+C
or Ctrl+D
.
You can also use files for input and output:
fold -sw 60 input.txt > output.txt
Linux: How to make a terminal window title reflect the current path
By default, your terminal emulator (Gnome Terminal, Terminator, etc.) sets some kind of window title to reflect the shell type you are running (e.g. /bin/bash
).
This is most often not too helpful, but you can change that from your shell.
To set...
Grep the number of occurences in a file, counting multiple hits per line
Grep prints one line per match. To return the number if matches, use the -c
switch:
grep -c "something" filename
However, if a word appears more than once in a line, it is only counted once.
To count every match, you can use [sed
](http:...
Solve screen error "Cannot open your terminal '/dev/pts/0' - please check"
When using the screen
tool you may be unable to start a screen session but instead encounter an error:
Cannot open your terminal '/dev/pts/0' - please check.
This is because another user (you) initiated the current terminal -- you probably...
Linux: Open a file with the default application
If you are on a Linux shell and want to open a file with whatever default application is configured for that type, this often works:
xdg-open Quote.odt
xdg-open invoice.pdf
xdg-open index.html
Pro Tip
Make an alias so you ...
How to resize your boot partition when there is an encrypted partition after it
Boot partitions from installations prior to the 16.04 era are terribly small. When you install updates and encounter errors due to a full /boot
partition, consider risizing it.
If you can't do the steps described below, ask someone experienced ...
Paste X selections into your terminal with your keyboard
The buffer where text is put into when you double-click on text within X is called X selection.
You can paste this buffer (at least into a terminal window) by pressing Shift + Insert
.
Generate a strong secret from the shell
A good tool to generate strong passwords and secrets is "apg". You can get it with
sudo apt-get install apg
To create a strong secret for sessions, [hashed Paperclip paths](https://makandracards.com/makandra/734-deliver-paperclip-attachments...
Linux: How to print PDF files from the command line
Sometimes you may want to print files from the command line, especially when you have lots of them.
You can use lp
for that.
To print a single example.pdf
file on your default printer, simply say:
lp example.pdf
lp
accepts multipl...
Files open with an error "the location is not a folder" after installing XFCE
When using gnome-open
(i.e. double-clicking a file, telling to browser to open a download, etc.) on Ubuntu you may get this error:
The location is not a folder.
It's due to the exo-utils
package which [does not play nice with gnome-open
]...