Most Popular

1500 questions
91
votes
5 answers

Determine what device a directory is located on

If I do # cd / # ln -s /home test # cd test # mount --bind $PWD /mnt the entry in /proc/mounts is /dev/sda2 /mnt ext4 rw,noatime,data=ordered 0 0 which is the device that is mounted to /home and is not easily deducible from $PWD which is /test.…
StrongBad
  • 5,151
  • 9
  • 47
  • 73
91
votes
9 answers

Get list of subdirectories which contain a file whose name contains a string

How can I get a list of the subdirectories which contain a file whose name matches a particular pattern? More specifically, I am looking for directories which contain a file with the letter 'f' somewhere occurring in the file name. Ideally, the list…
Muhd
  • 1,024
  • 1
  • 8
  • 9
90
votes
9 answers

How to insert the result of a command into the text in vim?

For instance, :echo strftime(%c) will show the current time on the bottom, but how to insert this time string into the text (right after the cursor)?
xzhu
  • 1,272
  • 2
  • 11
  • 8
90
votes
7 answers

How to match case insensitive patterns with ls?

I would like to list all files matching a certain pattern while ignoring the case. For example, I run the following commands: ls *abc* I want to see all the files that have "abc" as a part of the file name, ignoring the case, like -rw-r--r-- 1 mtk…
mtk
  • 26,802
  • 35
  • 91
  • 130
90
votes
2 answers

An easy bash completion tutorial?

I want to learn how to write bash completion scripts. Which tutorial would you recommend?
tshepang
  • 64,472
  • 86
  • 223
  • 290
90
votes
6 answers

List all valid kbd layouts, variants and toggle options (to use with setxkbmap)

Is there a way from command line to retrieve the list of all available keyboard layouts and relative variants? I need to list all the valid layout/variants choices to be used then from setxkbmap. Also about the layout toggle options, is there a way…
giuspen
  • 1,295
  • 2
  • 12
  • 14
90
votes
4 answers

How do I change the default text editor in the Debian (squeeze) distro

"Joe's own editor" does not come naturally to me. How do I change to using nano or vim? I've tried export EDITOR=nano but it doesn't seem to be respected. I'd like visudo to respect this as well.
wmarbut
  • 1,001
  • 1
  • 8
  • 6
90
votes
5 answers

How can I make a program executable from everywhere

What should I do if I want to be able to run a given program regardless of my current directory? Should I create a symbolic link to the program in the /bin folder?
aneuryzm
  • 1,875
  • 4
  • 18
  • 18
90
votes
9 answers

How to disable `apt-daily.service` on Ubuntu cloud VM image?

The Ubuntu 16.04 server VM image apparently starts the "apt-daily.service" every 12 hours or so; this service performs various APT-related tasks like refreshing the list of available packages, performing unattended upgrades if needed, etc. When…
Riccardo Murri
  • 16,238
  • 4
  • 56
  • 46
90
votes
3 answers

How to step-into, step-over and step-out with GDB?

I typed help while I was in the GDB but didn't find anything about step-into, step-over and step-out. I put a breakpoint in an Assembly program in _start (break _start). Afterwards I typed next and it finished the debugging. I guess it was because…
Pichi Wuana
  • 1,159
  • 2
  • 9
  • 10
90
votes
13 answers

Tab completion errors: bash: cannot create temp file for here-document: No space left on device

When using the tab bar, I keep getting this error: bash: cannot create temp file for here-document: No space left on device" Any ideas? I have been doing some research, and many people talk about the /tmp file, which might be having some overflow.…
lucasrodesg
  • 1,002
  • 1
  • 7
  • 8
90
votes
4 answers

Understanding IFS

The following few threads on this site and StackOverflow were helpful for understanding how IFS works: What is IFS in context of for looping? How to loop over the lines of a file Bash, read line by line from file, with IFS But I still have some…
Amelio Vazquez-Reina
  • 40,169
  • 77
  • 197
  • 294
90
votes
5 answers

Set systemd service to execute after fstab mount

I'm working on a systemd .service script that is supposed to start after a CIFS network location is mounted via /etc/fstab to /mnt/ on boot-up. The script waits for an OpenVPN dependency script to launch first, but I also want it to wait for mount…
P A N
  • 1,661
  • 4
  • 18
  • 23
90
votes
4 answers

How to get last N commands from history?

I want to see what are the last N commands in my history. I thought history | tail -n 5 would make it, but I noticed that a multiline command counts for as many lines as it has. $ echo "hello how are you" $ history | tail -2 how are you" 1051 …
fedorqui
  • 7,603
  • 7
  • 35
  • 71
90
votes
2 answers

Trim audio file using start and stop times

I have an FFmpeg command to trim audio: ffmpeg -ss 01:43:46 -t 00:00:44.30 -i input.mp3 output.mp3 The problem I have with this command is that option -t requires a duration (in seconds) from 01:43:46. I want to trim audio using start/stop times,…
whitewings
  • 2,377
  • 7
  • 32
  • 53