Dan Carley
  • Member for 12 years, 8 months
  • Last seen more than 5 years ago
What's the best way to check if a volume is mounted in a Bash script?
Accepted answer
171 votes

Avoid using /etc/mtab because it may be inconsistent. Avoid piping mount because it needn't be that complicated. Simply: if grep -qs '/mnt/foo ' /proc/mounts; then echo "It's mounted." else ...

View answer
Running Cron every 2 hours
Accepted answer
150 votes

An asterisk in the minute (first) field tells it to run every minute, regardless of the other fields. You need to specify an exact minute to run within the hour. Be that on the hour (0), half past (...

View answer
SSL Certificate Location on UNIX/Linux
Accepted answer
123 votes

For system-wide use, OpenSSL should provide you /etc/ssl/certs and /etc/ssl/private. The latter of which will be restricted 700 to root:root. If you have an application that doesn’t perform initial ...

View answer
What is the difference between SAN, NAS and DAS?
119 votes

First it is best to define the difference between a block device and filesystem. This is easier grasped if you are familiar with UNIX because it makes an objective distinction between the two things. ...

View answer
How does Ubuntu keep track of the "System restart required" flag in motd?
Accepted answer
100 votes

Check for the presence of /var/run/reboot-required.

View answer
What is the difference between unlink and rm?
Accepted answer
77 votes

Both are a wrapper to the same fundamental function which is an unlink() system call. To weigh up the differences between the userland utilies. rm(1): More options. More feedback. Sanity checking. ...

View answer
How can I show mysql locks?
Accepted answer
56 votes

See Marko's link for InnoDB tables and the caveats. For MyISAM, there isn't a dead easy "this is the offending query" solution. You should always start with a processlist. But be sure to include the ...

View answer
Why su to root instead of logging in as root?
Accepted answer
43 votes

The inference is to only su or sudo when required. Most everyday tasks don't require a root shell. So it is good practice to use an unprivileged shell as your default behaviour and then only elevate ...

View answer
Reattach or create a named screen session? (or persistent screen sessions)
Accepted answer
34 votes

Tell screen to be a bit more persistent about trying: -D -R Attach here and now. In detail this means: If a session is run- ning, then reattach. If necessary detach and logout remotely ...

View answer
How can I read pcap files in a friendly format?
32 votes

Wireshark. You may never look back :) Incidentally you should make sure the snaplen of your original capture matches or exceeds the MTU of the traffic that you're capturing. Otherwise the contents ...

View answer
How to get pgrep to display full process info
Accepted answer
28 votes

pgrep's output options are pretty limited. You will almost certainly need to send it back through ps to get the important information out. You could automate this by using a bash function in your ~/....

View answer
How do I find (or exclude) all directories and sub-directories matching a certain pattern (in Linux)?
Accepted answer
26 votes

find . -type d -not \( -name .svn -prune \)

View answer
How do I validate a bind9 zone file?
Accepted answer
24 votes

The utility you are after is called named-checkzone. It's distributed with BIND.

View answer
how to split a pcap file into a set of smaller ones
23 votes

Use the editcap utility which is distributed with Wireshark.

View answer
How to restrict everyone except a certain group in SSH?
Accepted answer
20 votes

If you're using OpenSSH 5.1 or later then it supports Match Group negation. Assuming the defaults are OK for the admin group, then just change everyone else: Match Group *,!admin X11Forwarding ...

View answer
Linux/Debian - What does 'pee' in moreutils do?
20 votes

It's probably easier to understand if you've used tee first. This useful old tool takes standard input and writes out to multiple files, plus standard output. The following: echo "Hello world" | tee ...

View answer
List all symbolic links on a unix system
Accepted answer
19 votes

Use with some caution. It will take a while. find / -type l

View answer
Are there no downsides to NetApp SAN solutions other than price?
Accepted answer
18 votes

We have had some ups and downs. Including finding our first ONTAP bug before we'd deployed and producing some certain benchmark conditions that weren't quite what we expected. But that probably makes ...

View answer
protecting my files from root
Accepted answer
17 votes

Thinking about it logically - without touching on any specific technologies - if it's not your machine and you don't trust root then you have a problem. You really can't do anything about securing ...

View answer
What's the best way to check if an SMTP server is SSL-enabled or not?
Accepted answer
17 votes

That depends whether you mean SSL or TLS. SSL has it's own dedicated port at TCP/465. The best way to test for it's presence would be to use OpenSSL's wonderful s_client which will negotiate the SSL ...

View answer
How IP addresses are mapped to Autonomous System Numbers?
Accepted answer
16 votes

Note: This information is kind of RIPE-centric because that's the RIR I deal with most. The relationships between IPs (inet-num) and ASNs (aut-num) are documented in public Internet Routing ...

View answer
How can I replay Apache access logs back at my servers to do real world load testing?
Accepted answer
16 votes

You can use Jmeter's Access Log Sampler component. There's a short tutorial on it's use in this PDF.

View answer
Would you install phpmyadmin on a production web server?
Accepted answer
16 votes

Would you recomend installing/using phpMyAdmin on a prduction webserver? No, simply. phpMyAdmin has an infamous security history as detailed on SecurityFocus. You don't say what platform you're using,...

View answer
Bulk rename or delete in Linux
Accepted answer
16 votes

Review the offending files. find /path/to/files -name '*:*' -print Delete the offending files. find /path/to/files -name '*:*' -exec rm {} + Rename the offending files with an underscore. find /...

View answer
Techniques to Monitor cron tasks?
16 votes

My common approach is thus: Don't produce any stdout when your cron'ed application completes successfully. Don't pipe any output to /dev/null. Do produce meaningful stderr output when something goes ...

View answer
Where should I place group shared files on a Linux system?
Accepted answer
15 votes

I'd almost certainly suggest using /usr/local. Globally accessible user scripts can be placed in /usr/local/bin. Small amounts of associated data could also go into bin. Or you may wish to separate ...

View answer
Source based distros vs Prebuilt package based distros
Accepted answer
15 votes

I maintain more than a fair number of Gentoo machines. Not because we care for childish funroll-loops speed tuning. What we care about is the flexibility of installing precisely what we want, not ...

View answer
How to count all subfolders in an directory?
Accepted answer
14 votes

Use find to select the directories and wc to count them. find <directory> -mindepth 1 -type d | wc -l

View answer
ip address scope parameter
13 votes

To begin to understand the definition of scope you should start by knowing what link-local and site-local addresses are. Once those are cleared up then the others will fall into place. Quoting some ...

View answer
Un-tar a specific directory inside of a tar
Accepted answer
13 votes

To strip down the parent directory: tar zxvf latest.tar.gz --strip 1 If you want to be sure that nothing from the parent directory is extracted: tar zxvf latest.tar.gz --strip 1 wordpress/...

View answer
1
2 3 4 5
14