Browsing articles tagged with "commandline - 7/59 - Admins Goodies"
Dec 3, 2011
tom

How do I prevent accidental rm -rf /*?

Just run rm -rf /* accidentally, meant rm -rf ./* (notice the star after the slash) alias rm=’rm -i’ and –preserve-root by default didn’t save me, so are there any automatic safeguards for this? Yeah, I wasn’t root and canceled command immediately but there were some relaxed permissions somewhere or something because I noticed that my bash prompt broke already. I don’t want to rely on permissions and not being root (I could make same [...]

Continue Reading »
Dec 3, 2011
tom

Strange bash history behaviour when running multiple sessions

How is command line history stored when I use multiple terminal windows? I know it is stored in .bash_history but I can’t see the logic on what history is used if I open new window. It almost feels nondeterministic in a sense that I never know what command I will see if I try to use up arrow in new window. Can someone explain this? Is there a way to control history in such way [...]

Continue Reading »
Dec 1, 2011
tom

Can I change a user password in Linux from the command line with no interactivity?

I have a specific use case where I would really like to be able to change a user’s password with a single command with no interactivity. This is being done in a safe fashion (over SSH, and on a system with only one user able to be logged in), so it’s fine to expose the new password (and even the old one, if necessary) on the command line. FWIW, it’s a Ubuntu system. I just [...]

Continue Reading »
Dec 1, 2011
tom

Listing of files recursively with modified time in tree-like format

I’m looking for a single command to list all files recursively from a given directory along with its modified time. It would also be nice if it can produce output in a tree-like format as produced by tree command. NOTE: I’m running Red Hat Enterprise Linux Server release 5. EDIT: The option -D of tree command prints only the date part of the last modification time for past years, though it display date with time [...]

Continue Reading »
Dec 1, 2011
tom

/data/tmp on database server? [closed]

I am on a Linux ubuntu machine with MySQL installed. My teacher gave out an assignment which mentioned “copy cars.dat to /data/tmp on the MySQL database server” without any explanations, I do not know what is the “/data/tmp on database server” means exactly? Basically after that I need to execute SQL statement like LOAD DATA INFILE ‘/data/tmp/cars.dat’ INTO TABLE cars So, what does copy cars.dat to /data/tmp on the database server means as there is [...]

Continue Reading »
Dec 1, 2011
tom

How to configure Sendmail?

How can I learn to configure sendmail on Unix-aix? Note that I don’t have a DNS server. I recommend grabbing O’Reilly’s Sendmail book (Bat on front). Check more discussion of this question. Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Print for later Bookmark in Browser Tell a friend

Continue Reading »
Dec 1, 2011
tom

Incremental backups of Subversion repositories

I have two SVN repositories, svn_rep1 and svn_rep2. I want to back them up to a remote server, with an incremental backup daily and a full backup monthly. How I can write a bash shell script to do this operation? I ask you because I do not have time to search on my own. I’d recommend rsync for 1-to-1-copies and duplicity for incremental encrypted backups. Check more discussion of this question. Bookmark on Delicious Digg [...]

Continue Reading »
Nov 30, 2011
tom

“chown mysql:mysql /data/tmp” command

I am on a Linux ubuntu machine with MySQL installed. If there is a MySQL installation on a Ubuntu machine, I saw some people doing the following thing: sudo chown mysql:mysql /data/tmp I get confused, I know the meaning of the above command, which is to change the owner of /data/tmp to user ‘mysql‘ and change the group of it to ‘mysql‘ group. But (my questions): 1. Why would one run the above command? If [...]

Continue Reading »
Nov 23, 2011
tom

What’s the best way to upgrade to centos 6

We have a CentOS 5 system with a few programs php, apache etc. It’s our local office server as well so we want to keep downtime to a minimum. What’s the best way to upgrade to CentOS 6. I also just like to point out that our web connection is pretty rubbish so any quick cheap steps we can take to just get it going and then get extras as and when would be great. [...]

Continue Reading »
Nov 23, 2011
tom

Can the Linux ps command output be filtered by user AND command?

I need the pid for a process given its owner and its command. I can filter a process per user with “ps -u xxx” and its command by “ps -C yyy”, but when I try “ps -u xxx -C yyy”, they are combined using OR logic. I need AND logic. How can I accomplish this? Use pgrep? pgrep -U xxx yyy it returns just the pid (or pids, if more than one process matches). Check [...]

Continue Reading »