Most Popular

1500 questions
182
votes
3 answers

Finding all large files in the root filesystem

I have a linux server, which currently has below space usage: /dev/sda3 20G 15G 4.2G 78% / /dev/sda6 68G 42G 23G 65% /u01 /dev/sda2 30G 7.4G 21G 27% /opt /dev/sda1 99M 19M 76M 20%…
182
votes
5 answers

How to get only files created after a date with ls?

With the ls command, is it possible to show only the files created after a specific date, hour...? I'm asking it because I have a directory with thousand of files. I want so see all files that were created since yesterday. I use ls -ltr but I have…
Luc M
  • 4,095
  • 5
  • 30
  • 29
181
votes
1 answer

How to clean log file?

Is there a better way to clean the log file? I usually delete the old logfile and create a new logfile and I am looking for a shorter type/bash/command program. How can I use an alias?
Micromega
  • 4,211
181
votes
8 answers

Get SSH server key fingerprint

Is there a way to programmatically obtain a SSH server key fingerprint without authenticating to it? I'm trying ssh -v user@host false 2>&1 | grep "Server host key", but this hangs waiting for a password if key based auth is not setup.
loopbackbee
  • 4,602
180
votes
4 answers

What does ampersand mean at the end of a shell script line?

sh sys-snap.sh & What is sh? What is sys-snap.sh? Why I should put & at the end of the line? Can anyone explain the syntax? Without the & the script won't go back to the prompt till I press Ctrl+C. With & I can press enter and it works.
user4951
  • 10,519
180
votes
8 answers

Can I "export" functions in bash?

source some_file some_file: doit () { echo doit $1 } export TEST=true If I source some_file the function "doit" and the variable TEST are available on the command line. But running this script: script.sh: #/bin/sh echo $TEST doit test2 Will…
Nils
  • 18,492
180
votes
6 answers

How to make a machine accessible from the LAN using its hostname

Here are details of the machine I want to access using its hostname: $ hostname hostname $ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 hostname.company.local hostname It's a default Debian 6 (Squeeze) install, so I didn't fiddle with anything…
tshepang
  • 65,642
180
votes
2 answers

What is the Fedora equivalent of the Debian build-essential package?

What is the Fedora equivalent of the Debian build-essential package?
179
votes
1 answer

When is double-quoting necessary?

The old advice used to be to double-quote any expression involving a $VARIABLE, at least if one wanted it to be interpreted by the shell as one single item, otherwise, any spaces in the content of $VARIABLE would throw off the shell. I understand,…
kjo
  • 15,339
  • 25
  • 73
  • 114
179
votes
3 answers

How to redirect output to a file from within cron?

I have a backup script which I need to run at a particular time of a day so I am using cron for this task and from within cron am also trying to redirect the output of backup script to a logfile. crontab -e */1 * * * * /home/ranveer/backup.sh &>>…
RanRag
  • 5,875
179
votes
1 answer

What is the difference between modify and change in stat command context?

The stat command's manual page says: %x Time of last access %y Time of last modification %z Time of last change I cannot understand the difference between modify and change. I understand the words are synonyms (English is not…
179
votes
1 answer

How to apt-delete-repository?

I would like to run the reverse of this command to remove the non-compatible repository in Debian 8.1 sudo add-apt-repository -y ppa:nemh/systemback where the command add-apt-repository is in the package software-properties-common. I could not…
179
votes
1 answer

Executing chdir before starting systemd service

Question: Can I kick off a process with systemd and assign that process a working directory of my choosing? I have a service that I want to start with systemd. When that service is being started, I want to be able to assign it a current working…
Mario
  • 1,985
179
votes
9 answers

How to find out the dynamic libraries executables loads when run?

I want to find out the list of dynamic libraries a binary loads when run (With their full paths). I am using CentOS 6.0. How to do this?
nakiya
178
votes
7 answers

How to run a program in a clean environment in bash?

I want to run a program in an empty environment (i.e. with no envariables set). How to do this in bash?