Most Popular

1500 questions
508
votes
11 answers

How do I remove a user from a group?

Which command should I use to remove a user from a group in Debian? When adding a user to a group, it can be done with: usermod -a -G group user However, I could not find a similar command (accepting a group and user as arguments) for removing the…
Lekensteyn
  • 20,830
494
votes
10 answers

How do I delete a file whose name begins with "-" (hyphen a.k.a. dash or minus)?

How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory: tohru:~ $ ls -l total 8 -rw-r--r-- 1 me staff 1352 Aug 18 14:33 --help ... How in the…
Astra
  • 5,043
491
votes
6 answers

What does "LC_ALL=C" do?

What does the C value for LC_ALL do in Unix-like systems? I know that it forces the same locale for all aspects but what does C do?
jcubic
  • 9,932
488
votes
5 answers

Why not use "which"? What to use then?

When looking for the path to an executable or checking what would happen if you enter a command name in a Unix shell, there's a plethora of different utilities (which, type, command, whence, where, whereis, whatis, hash, etc). We often hear that…
486
votes
5 answers

How does reverse SSH tunneling work?

As I understand this, firewalls (assuming default settings) deny all incoming traffic that has no prior corresponding outgoing traffic. Based on Reversing an ssh connection and SSH Tunneling Made Easy, reverse SSH tunneling can be used to get around…
Ali
  • 5,341
484
votes
3 answers

What should/shouldn't go in .zshenv, .zshrc, .zlogin, .zprofile, .zlogout?

I'm looking for guidelines on what one should and should not include in the various startup files for zsh. I understand the order of sourcing of these files, and the conditions under which they are sourced, but it is still not clear to me what…
kjo
  • 15,339
  • 25
  • 73
  • 114
477
votes
11 answers

How do I use pushd and popd commands?

What are the practical uses of both pushd and popd when there is an advantage of using these two commands over cd and cd -? EDIT: I'm looking for some practical examples of uses for both of these commands or reasons for keeping stack with…
syntagma
  • 12,311
472
votes
5 answers

What is the difference between curl and wget?

I am keen to know the difference between curl and wget. Both are used to get files and documents but what the key difference between them. Why are there two different programs?
lakshmen
  • 6,241
459
votes
6 answers

Delete from cursor to end of line in `vi`

I know I've probably looked over this a million times in all the vi documents I've read, but I can't seem to find the delete from cursor to end of line command.
Falmarri
  • 13,047
459
votes
11 answers

How can I run a command which will survive terminal close?

Sometimes I want to start a process and forget about it. If I start it from the command line, like this: redshift I can't close the terminal, or it will kill the process. Can I run a command in such a way that I can close the terminal without…
Matthew
  • 5,537
458
votes
2 answers

Using 'sed' to find and replace

I know this question has probably been answered before. I have seen many threads about this in various places, but the answers are usually hard to extract for me. I am looking for help with an example usage of the 'sed' command. Say I wanted to…
roo
  • 4,731
453
votes
4 answers

find's "-exec rm {} \;" vs "-delete"

I'm trying to understand the difference between these two commands: find / -name .DS_Store -delete and find / -name ".DS_Store" -exec rm {} \; I noticed that the -exec ... {} method is preferred. Why? Which one is safer/faster/better? I've used…
Onion
  • 4,641
447
votes
18 answers

How can I use sed to replace a multi-line string?

I've noticed that, if I add \n to a pattern for substituting using sed, it does not match. Example: $ cat > alpha.txt This is a test Please do not be alarmed $ sed -i'.original' 's/a test\nPlease do not/not a test\nBe/' alpha.txt $ diff…
443
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,759
441
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,639