Most Popular

1500 questions
142
votes
1 answer

How to do a `tail -f` of log rotated files?

On a long running system I usually have a terminal with $ tail -f /var/log/kern.log or something like this open. But from time to time I have to restart such command because no new messages are displayed anymore. I assume this is because of the log…
maxschlepzig
  • 56,316
  • 50
  • 205
  • 279
142
votes
7 answers

Cause a script to execute after networking has started?

I am relatively new to systemd and am learning its architecture. Right now, I'm trying to figure out how to cause a custom shell script to run. This script needs to run after the networking layer has started up. I'm running Arch, using systemd as…
fdmillion
  • 2,748
  • 3
  • 20
  • 21
141
votes
6 answers

What is the purpose of the hash command?

If you run hash it shows the path of all commands run since the hash was last reset (hash -r) [root@c04c ~]# hash hash: hash table empty [root@c04c ~]# whoami root [root@c04c ~]# hash hits command 1 /usr/bin/whoami [root@c04c ~]#…
spuder
  • 17,643
  • 36
  • 91
  • 119
141
votes
4 answers

What is the difference between reboot , init 6 and shutdown -r now?

I just want to know difference between in reboot init 6 shutdown -r now and which is the safest and the best?
Rahul Patil
  • 24,281
  • 25
  • 80
  • 96
141
votes
3 answers

Why do most systemd examples contain WantedBy=multi-user.target?

I have read what is multi-user.target and the systemd documentation, which states that the multi-user.target is a special target. Further, a lot of the systemd examples contain that line. Why do so many example services contain that line? What…
Carl
  • 1,513
  • 2
  • 10
  • 6
141
votes
1 answer

Understanding the -exec option of `find`

I find myself constantly looking up the syntax of find . -name "FILENAME" -exec rm {} \; mainly because I don't see how exactly the -exec part works. What is the meaning of the braces, the backslash and the semicolon? Are there other use cases for…
Zsolt Szilagy
  • 1,537
  • 2
  • 10
  • 7
141
votes
4 answers

What is the difference between "&&" and ";" when chaining commands

What is the difference between the following methods of chaining commands? cmd1; cmd2 cmd1 && cmd2
varesa
  • 2,336
  • 5
  • 20
  • 19
141
votes
3 answers

Pass command line arguments to bash script

I am new to bash script programming. I want to implement a bash script 'deploymLog', which accepts as input one string argument(name). [root@localhost Desktop]# ./deploymLog.sh name here I want to pass the string argument(name) through command line…
chinchu
141
votes
4 answers

Is there a ".bashrc" equivalent file read by all shells?

Is ~/.bashrc the only place to specify user specific environment variables, aliases, modifications to PATH variable, etc? I ask because it seems that ~/.bashrc seems to be bash-only, but other shells exist too…
Stefan
  • 24,830
  • 40
  • 98
  • 126
141
votes
4 answers

Cron vs systemd timers

It was recently pointed out to me that an alternative to cron exists, namely systemd timers. However, I know nothing about systemd or systemd timers. I have only used cron. There is a little discussion in the Arch Wiki. However, I'm looking for a…
Faheem Mitha
  • 34,649
  • 32
  • 119
  • 183
141
votes
9 answers

The myths about malware in Unix / Linux

Is it possible for my Linux box to become infected with a malware? I haven't heard of it happening to anyone I know, and I've heard quite a few times that it isn't possible. Is that true? If so, what's up with Linux Anti-Virus (security) software?
Stefan
  • 24,830
  • 40
  • 98
  • 126
141
votes
11 answers

Script to change current directory (cd, pwd)

I want to run a script to simply change the current working directory: #!/bin/bash cd web/www/project But, after I run it, the current pwd remains unchanged! How can I do that?
Sony Santos
  • 1,513
  • 2
  • 10
  • 7
141
votes
6 answers

tput setaf color table? How to determine color codes?

I am in the process of colorizing my terminal’s PS1. I am setting color variables using tput; for example, here’s purple: PURPLE=$(tput setaf 125) Question: How do I find the color codes (e.g. 125) of other colors? Is there a color table…
mhulse
  • 1,729
  • 2
  • 15
  • 12
141
votes
12 answers

How can I fix "cannot find a valid baseurl for repo" errors on CentOS?

I finished installing CentOS 6, but when I tried running yum update I got: [root@centos6test ~]# yum update Loaded plugins: fastestmirror, refresh-packagekit Determining fastest mirrors Could not retrieve mirrorlist…
shivshankar
  • 1,538
  • 2
  • 9
  • 7
141
votes
6 answers

Where do files go when the rm command is issued?

Recently I accidentally did rm on a set of files and it got me thinking where exactly these files end up? That is to say, when working with a GUI, deleted files go to the Trash. What's the equivalent for rm and is there a way of undoing an rm…
boehj
  • 2,580
  • 4
  • 23
  • 22