Most Popular
1500 questions
139
votes
4 answers
How to insert text after a certain string in a file?
Right now I'm using
echo "Hello World" >> file.txt
to append some text to a file but I also need to add text below a certain string let's say [option], is it possible with sed?
EG:
Input file
Some text
Random
[option]
Some stuff
Output file
Some…

Javier Villanueva
- 1,697
139
votes
3 answers
Getting new files to inherit group permissions on Linux
I am having a problem with permissions on a Linux server. I am used to BSD. When a directory is owned by a group the user who owns it isn't in such as www-data, files created in it will be owned by that group. This is important because I want files…

John Tate
- 1,960
139
votes
12 answers
How to rsync over ssh when directory names have spaces
I am trying to rsync from one server to another. The servers have the same directory structure but I am having trouble getting the remotes server to properly recognize the path name on the remote when there is a space in it.
Here are the…

PyNEwbie
- 1,569
138
votes
8 answers
How do I kill all screens?
I accidentally created over 1000 screens. How do I kill them all with one command? (Or a few)

BrainStone
- 3,654
138
votes
9 answers
In linux, how to delete all files EXCEPT the pattern *.txt?
I know how to delete all txt file under current directory by rm *.txt.
Does anyone know how to delete all files in current directory EXCEPT txt file?

Firegun
- 1,839
- 3
- 15
- 9
138
votes
3 answers
Pseudo files for temporary data
I often want to feed relatively short string data (could be several lines though) to commandline programs which accept only input from files (e.g. wdiff) in a repeated fashion. Sure I can create one or more temporary files, save the string there and…

highsciguy
- 2,574
138
votes
12 answers
How do I know if a partition is ext2, ext3, or ext4?
I just formatted stuff. One disk I format as ext2. The other I want to format as ext4. I want to test how they perform.
Now, how do I know the kind of file system in a partition?

user4951
- 10,519
138
votes
10 answers
Keyboard set to "cat mode"
I am a cat-owner and a cat-lover. But I don't like it when my cat sits on my keyboard and pushes randoms keys and messes everything up.
I have an idea to have a function key that turns off the keyboard (except for one special key combination). I…

psitae
- 1,481
138
votes
1 answer
Attach to different windows in session
I have a pretty simple tmux session running with two open windows; one of them for local hacking and one of them for work.
What I'd like to do is to simply connect to the hacking window while leaving the work window open in another terminal.…

Naftuli Kay
- 39,676
138
votes
4 answers
Why are there so many different ways to measure disk usage?
When I sum up the sizes of my files, I get one figure. If I run du, I get another figure. If I run du on all the files on my partition, it doesn't match what df claims is used. Why are there so many different figures for the total size of my files?…

Gilles 'SO- stop being evil'
- 829,060
137
votes
5 answers
Why isn't Linux embraced as the official GNU kernel?
While I knew for quite some time the existence of Hurd, and its mission as the official GNU Operating System kernel, I was wondering how come Linux is not embraced as the official GNU kernel over the years, seeing as it is in a much better state…

NlightNFotis
- 7,575
137
votes
9 answers
How to grep lines which does not begin with "#" or ";"?
I want to grep smb.conf and see only lines which are not commented.

denys
- 1,649
137
votes
4 answers
Throttle the download speed of wget or curl while downloading
Is it possible to throttle (limit) the download speed of wget or curl ?
Is it possible to change the throttle value while it is downloading ?

Gautam
- 2,335
- 5
- 18
- 18
137
votes
6 answers
Sorting the output of "find -print0" by piping to the "sort" command
I need to be able to alphabetically sort the output of find before piping it to a command. Entering | sort | between didn't work, so what could I do?
find folder1 folder2 -name "*.txt" -print0 | xargs -0 myCommand

Industrial
- 1,801
- 4
- 14
- 13
137
votes
4 answers
How do you detach the 2nd screen from within another screen?
I've accidentally attached to a 2nd GNU screen session from within an existing screen session and cannot detach or issue commands to the inner screen. I remember figuring out how to do that before but completely forgot and would like to keep it as…

Artem Russakovskii
- 1,505
- 2
- 9
- 9