Most Popular
1500 questions
427
votes
16 answers
In Bash, when to alias, when to script and when to write a function?
Noone should need 10 years for asking this question, like I did. If I were just starting out with Linux, I'd want to know: When to alias, when to script and when to write a function?
Where aliases are concerned, I use aliases for very simple…
ixtmixilix
- 13,040
- 27
- 82
- 118
420
votes
18 answers
How do I change the extension of multiple files?
I would like to change a file extension from *.txt to *.text. I tried using the basename command, but I'm having trouble changing more than one file.
Here's my code:
files=`ls -1 *.txt`
for x in $files
do
mv $x "`basename $files…
afbr1201
- 4,529
- 5
- 22
- 18
420
votes
3 answers
What are the shell's control and redirection operators?
I often see tutorials online that connect various commands with different symbols. For example:
command1 | command2
command1 & command2
command1 || command2
command1 && command2
Others seem to be connecting commands to files:
command1 >…
terdon
- 234,489
- 66
- 447
- 667
414
votes
2 answers
How to list keys added to ssh-agent with ssh-add?
How and where can I check what keys have been added with ssh-add to my ssh-agent?
Patryk
- 13,556
- 22
- 53
- 61
413
votes
2 answers
Compress a folder with tar?
I'm trying to compress a folder (/var/www/) to ~/www_backups/$time.tar where $time is the current date.
This is what I have:
cd /var/www && sudo tar -czf ~/www_backups $time"
I am completely lost and I've been at this for hours now. Not sure if…
qwerty
- 4,271
- 5
- 16
- 13
412
votes
15 answers
What are the pros and cons of Vim and Emacs?
How would you compare these editors? What are the pros and cons of each?
[note] This is not meant to be answered by those who "hate one and love another" or those who haven't used both.
John Berryman
- 735
- 5
- 9
- 17
410
votes
13 answers
How can I find broken symlinks
Is there a way to find all symbolic links that don't point anywere?
find ./ -type l
will give me all symbolic links, but makes no distinction between links that go somewhere and links that don't.
I'm currently doing:
find ./ -type l -exec file…
gabe.
- 11,644
- 11
- 44
- 58
409
votes
17 answers
How to do integer & float calculations, in bash or other languages/frameworks?
Using echo "20+5" literally produces the text "20+5".
What command can I use to get the numeric sum, 25 in this case?
Also, what's the easiest way to do it just using bash for floating
point? For example, echo $((3224/3807.0)) prints 0 :(.
I am…
Michael Durrant
- 41,213
- 69
- 165
- 232
408
votes
20 answers
GPU usage monitoring (CUDA)
I installed CUDA toolkit on my computer and started BOINC project on GPU. In BOINC I can see that it is running on GPU, but is there a tool that can show me more details about that what is running on GPU - GPU usage and memory usage?
pbm
- 24,747
- 6
- 36
- 51
408
votes
8 answers
Remove all files/directories except for one file
I have a directory containing a large number of files. I want to delete all files except for file.txt . How do I do this?
There are too many files to remove the unwanted ones individually and their names are too diverse to use * to remove them all…
Kantura
- 4,555
- 4
- 14
- 12
404
votes
13 answers
How can I get the size of a file in a bash script?
How can I get the size of a file in a bash script?
How do I assign this to a bash variable so I can use it later?
haunted85
- 4,201
- 2
- 15
- 9
403
votes
5 answers
Does curl have a timeout?
So far I couldn't find anything really, but is it true that curl doesn't really time out at all?
user@host:~# curl http://localhost/testdir/image.jpg
I'm asking because I'm redirecting any request for images in testdir to a separate Apache module…
Preexo
- 4,613
- 4
- 19
- 21
403
votes
14 answers
How to know whether Wayland or X11 is being used
I just installed the latest Kali Linux on my laptop which was based on Debian 7 (oldstable). I then dist-upgrad-ed the whole thing to Debian 8.
I've always wanted Wayland instead of X11, so I installed the necessary packages. Then created a minimal…
Dehbop
- 4,259
- 3
- 11
- 7
401
votes
18 answers
How can I prevent 'grep' from showing up in ps results?
When I search for some process that doesn't exist, e.g.
$ ps aux | grep fnord
wayne 15745 0.0 0.0 13580 928 pts/6 S+ 03:58 0:00 grep fnord
Obviously I don't care about grep - that makes as much sense as…
Wayne Werner
- 11,463
- 8
- 29
- 43
401
votes
9 answers
How to get over "device or resource busy"?
I tried to rm -rf a folder, and got "device or resource busy".
In Windows, I would have used LockHunter to resolve this. What's the linux equivalent? (Please give as answer a simple "unlock this" method, and not complete articles like this one.…
ripper234
- 31,063
- 43
- 82
- 90