All Questions

Filter by
Sorted by
Tagged with
16 votes
3 answers
26k views

cp --no-target-directory explained

Question: I need a simple example of how to use cp --no-target-directory. I do experience some difficulties in understanding cp --no-target-directory. I do understand the explanation for mv --no-...
erch's user avatar
  • 5,040
16 votes
3 answers
27k views

How do I remove all files in a folder except just some specified files?

I want to remove all files in a directory while leaving just some specified files, they don't have anything in common by name. How could I achieve that? For example, the file names I want to keep are:...
AGamePlayer's user avatar
  • 7,605
16 votes
2 answers
35k views

How to tell rsyslog to create log file if not there?

Default behaviour by rsyslog is to append traces to an existing log file. Now, I've seen (CentOs, Scientific Linux) that when rsyslog is already running, you delete the log file (e.g. the one ...
fduff's user avatar
  • 5,035
16 votes
1 answer
38k views

Move free space from end of the drive to first partition with gparted

I am in a frustrating situation - no matter how I try, gparted won't let me assign the empty space to the first partition: The middle partition is blocking me from expanding /dev/sda1. I need to move ...
Tomáš Zato's user avatar
  • 1,776
16 votes
3 answers
2k views

Bash, always check $PWD as part of path?

Background: One of my colleagues who doesn't come from a Linux background asked me about using ./ before some commands and not others, so I explained to him how PATH works and how binaries are chosen ...
Christophe's user avatar
16 votes
6 answers
13k views

Find recursively all archive files of diverse archive formats and search them for file name patterns

At best I would like to have a call like this: $searchtool /path/to/search/ -contained-file-name "*vacation*jpg" ... so that this tool does a recursive scan of the given path takes all files with ...
mdo's user avatar
  • 271
16 votes
2 answers
22k views

How to pass a passphrase to ssh-add without triggering a prompt?

I read man ssh-add and I don't see a flag for passing a passphrase like we have in ssh which is -p. I tried # the -K is for macOS's ssh-add but it's not relevant ssh-add -q -K ~/.ssh/id_rsa <<&...
Christopher Francisco's user avatar
16 votes
3 answers
8k views

How can I instruct BSD sed to interpret escape sequences like \n and \t?

I have a sed replacement command that I would like to be compatible with BSD sed as well as GNU sed. Extended regular expressions are not an issue as I do not need them in this case. My primary ...
ephsmith's user avatar
  • 1,006
16 votes
2 answers
25k views

Why is $1 in a function not printing the script's first argument?

Why doesn't echo $1 print $1 in this simple bash script? #!/bin/bash # function.sh print_something () { echo $1 } print_something $ ./function.sh 123 -> why doesn't it print '123' as a result?
pietro letti's user avatar
16 votes
6 answers
4k views

Utility to buffer an unbounded amount of data in a pipeline?

Is there a utility that I can stick in a pipeline to decouple read and write speeds? $ producer | buf | consumer Basically, I want a utility buf that reads its input as fast as possible, storing it ...
Doctor J's user avatar
  • 671
16 votes
2 answers
30k views

Under what conditions exactly does SIGPIPE happen?

Say we have a named pipe called fifo, and we're reading and writing to it from two different shells. Consider these two examples: shell 1$ echo foo > fifo <hangs> shell 2$ cat fifo foo shell ...
Naïm Favier's user avatar
16 votes
4 answers
79k views

Terminal, Prompt changed to "-Bash-4.2" and colors lost

Usually my terminal prompt was username place$ now it only shows bash-4.2$ and all the color settings have been lost (on the terminal profile I have the same color scheme, but it just don't show ...
lcjury's user avatar
  • 263
16 votes
3 answers
25k views

Using in/out named pipes for a TCP connection

I've been fiddling with getting this to work for a while now, so I suspect some sort of fundamental misunderstanding about how pipes work is the root cause of my troubles. My goal is to initiate a ...
noffle's user avatar
  • 1,140
16 votes
2 answers
44k views

How to clean up bootloaders & UEFI entries from other installs?

I got a new Windows laptop, and I wanted to dual boot with Linux. I installed Fedora, before changing my mind and going back to Mint. I'd like to keep Win 8.1 and Mint. However, now my UEFI boot menu ...
Paul's user avatar
  • 261
16 votes
2 answers
12k views

What is the rationale behind EINTR?

Small talk as background EINTR is the error which so-called interruptible system calls may return. If a signal occurs while a system call is running, that signal is not ignored. If a signal handler ...
Hibou57's user avatar
  • 905
16 votes
8 answers
44k views

sed - remove the very last occurrence of a string (a comma) in a file?

I have a very large csv file. How would you remove the very last , with sed (or similar) ? ... [11911,0,"BUILDER","2014-10-15","BUILDER",0,0], [11912,0,"BUILDER","2014-10-15","BUILDER",0,0], [11913,...
spuder's user avatar
  • 18.1k
16 votes
1 answer
63k views

Start a background process from a script and manage it when the script ends

I'd like to run and configure a process similarly to a daemon from a script. My shell is zsh emulated under Cygwin and the daemon is SFK, a basic FTP server. For what matters here, the script ...
antonio's user avatar
  • 1,453
16 votes
3 answers
33k views

rpc.statd running on system not using NFS

I have a Debian machine that gets warnings (via the Tiger automatic auditor) that rcp.statd is listening on such-and-such socket. Googling shows rpc.statd is a daemon used by NFS. As far as I know, I'...
jrdioko's user avatar
  • 860
16 votes
3 answers
3k views

Count nul delimited items in file

I have a shell script which uses find -print0 to save a list of files to be processed into a temporary file. As part of the logging I'd like to output the number of files found, and so I need a way ...
qqx's user avatar
  • 2,588
16 votes
5 answers
19k views

Special File that causes I/O error

I want to automatically test if a piece of software reacts as expected if an essential SQLite DB file fails to be read (causing an I/O error). Exactly that happened some days ago at a client. We ...
mreithub's user avatar
  • 3,583
16 votes
2 answers
40k views

How can I completely reinstall mysql?

I had to reboot in the middle of a large data import. I only have one mysql database, which has now been corrupted. How can I completely remove mysql and reinstall it? I've tried apt-get purge mysql-...
cwd's user avatar
  • 45.4k
16 votes
1 answer
11k views

Why do these bash fork bombs work differently and what is the significance of & in it?

I get how a normal fork bomb works, but I don't really understand why the & at the end of the common bash fork bomb is required and why these scripts behave differently: :(){ (:) | (:) }; : and ...
Dan K.'s user avatar
  • 163
16 votes
2 answers
9k views

Cannot execute binary in NixOS - No such file or directory

I tried to install the current oracle jre on a VM running NixOS. Now the following happens: [michas@cc:~]$ tar xvzf jre-7u40-linux-x64.tar.gz |grep bin/java jre1.7.0_40/bin/javaws jre1.7.0_40/bin/...
michas's user avatar
  • 21.5k
16 votes
4 answers
18k views

Adding paths to PATH using a multi-line syntax

As far as I understand, the usual way to add a path to the PATH environment variable is by concatenating paths separated by the : character. For example, if I want to add three paths to it /my/path/...
Amelio Vazquez-Reina's user avatar
16 votes
3 answers
8k views

Can I limit a process to a certain amount of time / CPU cycles?

We have a script which runs on our web servers, triggered by customer action, which initiates a unix process to generate some cache files. Because this process acts upon files supplied by our customer,...
Josh's user avatar
  • 8,458
16 votes
4 answers
18k views

Can I setup a loopback audio device?

If I can send audio to the output devices, then I can record the same audio as a wave. With filesystems, you can just setup a loopback filesystem and write binary data on a file instead of a device. ...
D4RIO's user avatar
  • 1,576
16 votes
2 answers
8k views

Why are there so many virtual terminal devices?

I've been reading the Advanced Linux Programming book and it mentions about virtual terminals which, if I understood it correctly, it is a Linux-specific feature (not in Unix) to allow multiple login ...
ArmenB's user avatar
  • 325
16 votes
7 answers
10k views

Remove trailing new line from 'clipboard' to prevent execution on the terminal?

Is there some way to run whatever you copy to the 'clipboard' through some sort of filter? Ideally to strip out the trailing newline from something you copy, so that it doesn't auto-run in the ...
AncientSwordRage's user avatar
16 votes
2 answers
36k views

Is halt the same as "shutdown -H" and poweroff the same as "shutdown -P"?

I haven't found a clear answer to the differences between the two options to the command shutdown. Is halt the same as shutdown -H and poweroff the same as shutdown -P?
Tim's user avatar
  • 102k
16 votes
3 answers
41k views

ssh remote server on some port other than 22 without password

I am usually connecting to the remote server with ssh [email protected] -p 11000 and then giving the password each time for user. How should I avoid entering the password each time I connect using ...
Prabesh Shrestha's user avatar
16 votes
2 answers
14k views

Get directory from which script was called from

I have a script doSmth in /usr/bin. Is it possible to get and print the directory the script was called from? So if I call doSmth from /home/me the output will be /home/me.
c0dehunter's user avatar
16 votes
1 answer
7k views

background process pipe-input

if i want to display "aaa" on screen: (1)$: echo aaa | cat ... works OK (2)$: echo aaa | ( cat ) ... works OK (3)$: echo aaa | ( cat & ) ... NOT working (4)$:...
Asain Kujovic's user avatar
16 votes
3 answers
92k views

How can I cd into a directory as root?

Let's say there's a directory that I don't have the privileges to access. Obviously sudo cd foo won't work, because cd is a shell builtin in every shell ever. So far, I've just been using sudo bash (...
strugee's user avatar
  • 15k
16 votes
5 answers
8k views

How can I find out which files are lost through a ddrescue recovery atempt?

I am in the process of salvaging data from a 1 TB failing drive (asked about it in Procedure to replace a hard disk?). I have done ddrescue from a system rescue USB with a resulting error size of ...
David Sevilla's user avatar
16 votes
2 answers
8k views

Detach/reattach an application run on X over SSH?

I have a development server that I leave running all the time, and a development laptop that I turn off/on everyday. I have a GUI application on the server that I'd like to run over SSH -X, and I'd ...
LeeMobile's user avatar
  • 285
16 votes
6 answers
27k views

Unlock LUKS encrypted Debian root with key file on boot partition

I'm trying to decrypt the Debian root with a key file stored in the boot partition (decrypted partition). This will break the security, but it doesn't matter now. I have to conclude this successfully ...
Fusgyus's user avatar
  • 161
16 votes
3 answers
22k views

Split file into multiple small files, separate by the newline symbol

Is there a utility that split file by newline symbol? e.g if a file contains the following lines, aa bbb cccc If I want to split it to 3 files, the desired output would be: aa, bbb And cccc (in 3 ...
daisy's user avatar
  • 54.6k
16 votes
2 answers
65k views

Create and control start up scripts in BusyBox

I have compiled a custom linux kernel in BusyBox. BusyBox init does not support runlevels. When the kernel boots up in BusyBox, it first executes init which looks for the specified runlevel in /etc/...
Shantanu Banerjee's user avatar
16 votes
4 answers
60k views

Creating a snapshot of a linux system

I want to do the following - Save the current state of my linux OS(centOS6.5). Do some changes (more specifically inject a fault and test some service to check how it behaves when that particular type ...
bRuta's user avatar
  • 441
16 votes
1 answer
5k views

Double click selection in Gnome Terminal

Double clicking on a word in gnome terminal selects the whole word. Unfortunately, this selection doesn't include colons such that URLs aren't completely selected, e.g. with http://foo.example.org/ ...
maxschlepzig's user avatar
  • 57.6k
16 votes
4 answers
54k views

how to execute a bash script without typing ./ [duplicate]

It has been bugging me for a very long time and I'm really sick of it. For example there's a script called testscript that compares two directories. In class the prof can just type testscript dir1 ...
asura's user avatar
  • 309
16 votes
2 answers
71k views

Repairing python setup

On my Kubuntu 14.4 (which has python 2.7.6 as standard) my python is broken after I tried to install python 2.7.10 after building from source from python.org with the help of How to install the latest ...
Make42's user avatar
  • 657
16 votes
2 answers
33k views

reliable return code of background process

Let's assume the following piece of bash code: foo > logfile 2>&1 & foo_pid=$! while ps -p$foo_pid do ping -c 1 localhost done wait $foo_pid if [[ $? == 0 ]] then echo "foo ...
Christopher Schmidt's user avatar
16 votes
3 answers
20k views

Creating bootable Debian image with debootstrap

I have been trying to create a bootable debian (jessie/8.4) image for the past 2 days, and as far as I can tell I have the procedure right, but I can not get the filesystem right. I am relatively sure ...
ehiller's user avatar
  • 351
16 votes
2 answers
29k views

Why can't root on one machine change nfs mounted content from another machine?

On my NFS server, I have the following export defined: #NFS exports Database /shared -alldirs -network=192.168.1 -mask=255.255.255.0 On my NFS client: 192.168.1.7:/shared /shared nfs rw 0 0 ...
gabe.'s user avatar
  • 11.8k
16 votes
2 answers
25k views

Where does grep -r search by default?

I found if I search using grep without specifying a path, like grep -r 'mytext' it takes infinitely long. Meanwhile if I search with path specified grep -r 'mytext' . it instantly finds what I need. ...
user avatar
16 votes
1 answer
19k views

Pacman -Syu fails `/bin exists in filesystem`

I was trying to upgrade my arch linux with pacman -Syu after having returned from vacation and now I get this error that I cannot quite make sense of: (133/133) checking for file conflicts ...
wirrbel's user avatar
  • 311
16 votes
3 answers
19k views

How to get rid of desktop environment and use a window manager only?

I have been using xterm for all my work. I realized that the features that desktop environments like GNOME has to provide are not of much use to me. Now, is it possible that I remove GNOME and KDE ...
Andrew-Dufresne's user avatar
16 votes
1 answer
28k views

quotas not linked to users but to directories

Usually, quotas are enforced per user, as related to the proprietary of the file. Is it possible to apply a quota on a folder basis, in such a way, that a folder contents are limited in disk space?
Lorenz Meyer's user avatar
16 votes
3 answers
3k views

What was the reason of the non-preemptivity of older Linux kernels?

Why did the first Linux developers choose to implement a non-preemptive kernel? Is it to save synchronization? As far as I know, Linux was developed in the early '90s, when PCs had a single processor....
Narden's user avatar
  • 161

15 30 50 per page
1
128 129
130
131 132
523