Most Popular

1500 questions
113
votes
9 answers

Why is the root directory on a web server put by default in "/var/www"?

Tuxfiles says the following about the Linux directory structure: /var: This directory contains variable data that changes constantly when the system is running. FHS on /var says the following: /var contains variable data files. This includes…
jonallard
  • 1,596
  • 4
  • 14
  • 14
113
votes
4 answers

How to troubleshoot DNS with systemd-resolved?

How would you go about finding the DNS servers used by systemd-resolved, for troubleshooting purposes? Generally I can use dig and test the DNS servers shown in /etc/resolv.conf. (Or windows - ipconfig /all + nslookup). But that approach doesn't…
sourcejedi
  • 48,311
  • 17
  • 143
  • 296
113
votes
7 answers

How can I grep the results of FIND using -EXEC and still output to a file?

Better to explain on examples. I can: find . -name "*.py" -type f > output.txt But how can I store the output to the same file for: find . -name "*.py" -type f -exec grep "something" {} \ I can't just do find . -name "*.py" -type f -exec grep…
bakytn
  • 2,853
  • 8
  • 33
  • 37
113
votes
6 answers

How could we allow non-root users to control a systemd service?

With sysvinit, a sudoers entry like this would suffice: %webteam cms051=/sbin/service httpd * This would allow for commands such as: sudo service httpd status sudo service httpd restart Now, with systemd, the service name is the final argument.…
Belmin Fernandez
  • 9,347
  • 15
  • 46
  • 50
113
votes
6 answers

How to integrate mv command after find command?

I am searching for files which name which contain AAA within their path using following command: find path_A -name "*AAA*" Given the output showed by the above command, I want to move those files into another path, say path_B. Instead of moving…
huahsin68
  • 1,847
  • 8
  • 22
  • 25
112
votes
3 answers

What is difference between User space and Kernel space?

Is Kernel space used when Kernel is executing on the behalf of the user program i.e. System Call? Or is it the address space for all the Kernel threads (for example scheduler)? If it is the first one, than does it mean that normal user program…
Poojan
  • 1,231
  • 2
  • 9
  • 6
112
votes
5 answers

Why is root login via SSH so bad that everyone advises to disable it?

Everybody on the Internet advises to disable root login via SSH as it is a bad practice and a security hole in the system, but nobody explains why it is so. What is so dangerous in enabling root login (especially with disabled password login)? And…
rush
  • 27,055
  • 7
  • 87
  • 112
112
votes
3 answers

What are correct permissions for /tmp ? I unintentionally set it all public recursively

I have created a really really short life temporary directory that I wanted to share between some users for a few hours : /some/path/tmp Unfortunately I have launched sudo chown 777 -R /tmp instead of sudo chown 777 -R tmp, so my /tmp file is now…
Stephane Rolland
  • 4,147
  • 6
  • 37
  • 49
112
votes
7 answers

Creating a user without a password

I'm trying to create a user without password like this: sudo adduser \ --system \ --shell /bin/bash \ --gecos ‘User for managing of git version control’ \ --group \ --disabled-password \ --home /home/git \ git It's created…
Erik
  • 1,687
  • 3
  • 13
  • 11
112
votes
8 answers

Preventing grep from causing premature termination of "bash -e" script

This script does not output after: #!/bin/bash -e echo "before" echo "anything" | grep e # it would if I searched for 'y' instead echo "after" exit I could solve this by removing the -e option on the shebang line, but I wish to keep it so my…
iago-lito
  • 2,581
  • 4
  • 20
  • 35
112
votes
8 answers

Set volume from terminal

Is it possible to set the audio volume using the terminal instead of clicking the speaker icon in the top bar? The reason I want to do this is that my keyboard does not have volume increase/decrease buttons and I find it annoying to reach for the…
Tristian
  • 1,499
  • 2
  • 13
  • 13
112
votes
7 answers

Is there a basic tutorial for grep, awk and sed?

I've been a Linux user for a while, and I've a pretty decent understanding of most the common command line utilities. However, ones that come up and up again in relation to programming are grep, awk, and sed. About the only thing I've used grep for…
Macha
  • 3,760
  • 7
  • 30
  • 35
112
votes
3 answers

What's the difference between "realpath" and "readlink -f"

I've read a lot about the realpath command and how it has been deprecated with readlink -f being now recommended.  I have also seen in some places that the reason why realpath was introduced was for the lack of such functionality in readlink and…
Felipe Leão
  • 1,285
  • 2
  • 9
  • 10
112
votes
3 answers

How can I suppress output from grep, so that it only returns the exit status?

I have the grep command. I'm searching for a keyword from a file, but I don't want to display the match. I just want to know the exit status of the grep.
jackass27
  • 1,123
  • 2
  • 7
  • 5
111
votes
3 answers

How do I check if a file is a symbolic link to a directory?

I can check, if a file exists and is a symbolic link with -L for file in *; do if [[ -L "$file" ]]; then echo "$file is a symlink"; else echo "$file is not a symlink"; fi done and if it is a directory with -d: for file in *; do if [[ -d…
rubo77
  • 27,777
  • 43
  • 130
  • 199