I'm running Ubuntu 12.04 server from home and using Ubuntu One as backup site. I'm not great at scripts (beginner) so when writing bash scripts that I later crontab for backups, having to use "Ubuntu\ One" or similar methods messes things up. In fact, I had to do in my script "cd 'Ubuntu\ One'" in the script so I could skip using the directory structure in the tar command, cause it wouldn't work.  Any chance to rename the default "Ubuntu One" folder ? or is there some other easy way I'm just not seeing while handling tar commands ?  The following was what I was trying to do, does not work:  DEST_DIR="/home/user/Ubuntu\ One/backup"  tar -vczpf ${DEST_DIR}/${FNAME}-${TIMESTAMP}.tar.gz ${SRC_DIR} >> ${LOG}   This does work however:  cd /home/user/Ubuntu\ One  tar -vczpf ${FNAME}-${TIMESTAMP}.tar.gz ${SRC_DIR} >> ${LOG}   I wanted variables so I could backup more specific files and directories and use array later to sort out where stuff goes. Forcing me to "cd" to the U1 directory in the script kinda sucks.
120822
I would like to tell Ubuntu One to sync with '~/Public/Ubuntu One' rather than '~/Ubuntu One'. Since I'm using it on Arch Linux, I don't have any right-click option for that.  I tried to edit ~/.config/ubuntuone/syncdaemon.conf and add the line root_dir = ~/new/folder (as suggested ), but the file is automatically reverted to its previous state. Also, the command u1sdtool hangs and does apparently nothing - I have to use Ctrl + C to close it. Is there another way to setup the default Ubuntu One default local folder?
110327
I have separate scripts for tasks in bash. Here is the broken one:  #!/bin/bash PATH=/home/name/ mkdir $PATH cd $PATH &amp;&amp; echo "done." exit 0   Today it broke and first time it simply didn't want to run cd, but created directory. Second time it just said "mkdir command not found." Running this commands exactly with semicolon works fine. What the case?
36504
Say I do this:  tar cvf allfiles.tar $(&lt;mylist.txt)  and mylist.txt contains this:  /tmp/lib1 /tmp/path2/lib2 /path3/lib3   How to tar the files so the tarball contains just  lib1 lib2 lib3   with no directory structure at all?    The -C of --directory options are usually recommended (, ), but there are multiple directories so this doesn't work. Also, --xform looks like it requires a fixed pattern () which we do not have.
93422
I tried to set up a root cron job to run a Bash script as root, to run at minute 7,37, every hour, every day of month, every month. This script is located in /usr/bin and named tunlrupdate.sh. It updates the DNS of Tunlr.  $ ls -l /usr/bin/tunlrupdate.sh  -rwxr-xr-x 1 root root 2133 Sep 24 15:42 /usr/bin/tunlrupdate.sh   This Bash script is available .  When invoked the script writes what's happening in a log located in /var/log/tunlr.log  To add this root cron job I used the standard for root's crontab  sudo crontab -e   And inserted these 2 lines at the end. I expect cron to run the script as root.  # check for updated Tunlr DNS every 30 minutes at the hour + 7 mn and hour + 37 mn 07,37 * * * * root /usr/bin/tunlrupdate.sh   A later command sudo crontab -l confirmed that the cron job has been inserted.  I did reboot Ubuntu and was checking in the log file if the cron job was launched properly. However there is nothing in the logfile /var/log/tunlr.log meaning the job was never successfully launched.  I did check that if I run the script from the command line  sudo /usr/bin/tunlrupdate.sh   then the logfile is updated accordingly.  Why is this cron job not running as planned in my system?  UPDATE 1 : All the proposed solutions so far do not work. I thank Olli for a CLI to list the system log sudo grep CRON /var/log/syslog. However I did get a CRON error  CRON[13092]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] &amp;&amp; [ -d /var/lib/php5 ] &amp;&amp; find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php /maxlifetime) ! -execdir fuser -s {} 2&gt;/dev/null \; -delete)   with the suggested PATH= insertion &amp; use of absolute path from root for functions in the script or without this suggested solutions here. I still get this error.  After some searching I pinpointed the error in the file /usr/lib/php5/maxlifetime as is explained : Change #!/bin/sh -e --&gt; #!/bin/sh -x  Then listing the CRON error log in my system  sudo grep CRON /var/log/syslog Feb 11 18:07:01 Marius-PC CRON[14067]: (root) CMD (root /usr/bin/tunlrupdate.sh) Feb 11 18:07:01 Marius-PC CRON[14066]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)   I still don't get the bash script executing. This time no error is shown in the log. To get assurance this was not the content of the script I reduced the script to the following 3 lines:  #!/bin/bash LOGFILE=/var/log/tunlr.log echo $LOGFILE &gt;&gt; $LOGFILE   I still don't get the cron job through. Nothing is written in the log file. So even may be an empty script will not run in cron ? I don't get it. I am know trying a script reduced to these 2 lines:  #!/bin/bash exit 0   And still the same error log. The cron script does not go through ...
72295
I am new to Linux and Ubuntu and have tried changing to folders/directories with some difficulty.  Could someone explain why the following commands failed to change to the desired target folder/directory?  sharon@sharon:~$ cd Home  bash: cd: Home: No such file or directory  sharon@sharon:~$ cd /Home  bash: cd: /Home: No such file or directory  sharon@sharon:~$ cd Documents  sharon@sharon:~/Documents$ cd Downloads  bash: cd: Downloads: No such file or directory  sharon@sharon:~/Documents$ cd /Downloads  bash: cd: /Downloads: No such file or directory  sharon@sharon:~/Documents$
87437
I'm trying to beat my head against the syntax of this. I'm getting problems with whitespaces and I can't see if there's a better way to do this.  vardir=/home/user cd $vardir for i in $(ls "$vardir") ; do timestamp="$(stat -c %Y $i)" echo "$i" echo "$timestamp"  done   Result is similar no matter where I quote and I'm not sure what I'm doing wrong:  stat: cannot stat ‘Temporary’: No such file or directory Temporary  stat: cannot stat ‘Items’: No such file or directory Items   My goal is I want to grab the timestamps off of backup directories and touch the current ones to restore the original modified dates.
97449
I want to write the Ubuntu analogue of a "batch file" (a shell script). But I don't know how to use chmod +x filename command to make it so that the script can be run. Nor do I know where to use it.
83915
I'd like to write a bash scipt that would change to target directory and list the contents of new directory, all in one step. It would replace the two commands I constantly use consecutively:   cd ./some_directory ls -al   After executing the script, my current directory would change, and ls -al would show the dir list.   cdl ./some_directory   Is this possible?
39779
I've searched for multiple forums for this questions and have seen different answers but so far, nothing have worked yet even from the ones I've seen here.  I want to extract a single file from a tar to a different directory.  I've tried this:  tar xvf file.tar -C /home/dir/ filename   or this:  tar -x filename -f file.tar -C /home/dir   But got these errors respectively:  x filename, 14826 bytes, 29 media blocks. File -C not present in the archive. File /home/dir not present in the archive.   and:  tar: /dev/rmt0: A file or directory in the path name does not exist.   The first extracted the file but in the same directory, not to the folder I wanted.
54550
I am wondering to ask the difference of these two commands (i.e. only the order of their options are different):   tar -zxvf foo.tar.gz tar -zfxv foo.tar.gz   The first one ran perfectly but the second one said:  tar: You must specify one of the `-Acdtrux' or `--test-label'  options Try `tar --help' or `tar --usage' for more information.   And tar with --test-label and -zfxv said :  tar (child): xv: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now   Then I looked at tar manual and realised that all the example there are using switch -f in the end!!  AFAICT there is no need for this restriction, or is there?! because in my view switches should be order free.
32124
I want to cd into /var/named but it gives me a permission denied error, and when I want to use sudo to do this I am not permitted. What is the technical reason for this, and is it possible to do this some other way?
35519
Is there any way to make/run a bash script on reboot (like in Debian/Ubuntu for instance, since thats what my 2 boxes at home have)  Also, any recommended guides for doing cron jobs? I'm completely new to them (but they will be of great use)
6411
What is the best way to copy a directory (with sub-dirs and files) from one remote Linux server to another remote Linux server? I have connected to both using SSH client (like Putty). I have root access to both.
8187
Writing my first script so I'm sure this is a basic question, but can someone please explain to me why I can:  cd ~ cd bin cd ~/bin cd 'bin'   But not  cd '~' cd '~/bin'   I need to cd to a directory path with a space in one of the directory names, so I need the quotes (it's Windows Program Files under wine). I can get around it with two cd commands, but why can't I put ~ in quotes?  If I type cd '~' (or cd "~") I get:  bash: cd: ~: No such file or directory
12086
root@server # tar fcz bkup.tar.gz /home/foo/ tar: Removing leading `/' from member names   How can I solve this problem and keep the / on file names ?
116209
I am migrating my home directory from an old system to a new one, and the tarball I made contains everything, including hidden files like .bashrc. However, when I move the contents of the unpacked tarball (which are in /tmp) to my new home directory, the hidden files do not copy (mv /tmp/home/rcook/* /home/rcook/). How can I get mv to move them?  Actually, I think the problem is not with mv, but with bash's globbing. If I do this:  mkdir a mkdir b touch a/.foo touch a/bar mv a/* b/ ls -a a/ b/   I see this:  a/: .  ..  .foo  b/: .  ..  bar   a/.foo did not move. So how can I get the * wildcard to find hidden files?  Yes, I suppose I could decompress the tarball directly into my home directory, but the tarball decompresses into home/rcook/..., and I want to be sure I overwrite the new .bashrc, etc. with the old, customized versions, and knowing how to find and move hidden files is a worthwhile skill. Suggestions?    Some answers suggest doing something like mv src/.* dest/. However, I tried this on my test directories and got errors. Starting with:  rcook$ ls -a a/ b/ a/: .  ..  bar  .foo  b/: .  .. rcook$ mv a/.* b/ mv: cannot move 'a/.' to 'b/.': Device or resource busy mv: cannot remove 'a/..': Is a directory rcook$ ls -a a/ b/ a/: .  ..  bar  b/: .  ..  .foo   What am I doing wrong?
29306
There are several files I work with often. For instance some configuration files or log files. Let's say the Apache log file. I often want to tail or grep it. Instead of writing:  tail -50 /var/log/apache2/error_log   I prefer to write  tail -50 apachelog  So that apachelog functions as an alias for this filename. But if I define an alias in my bashrc, it needs to be a whole command; it (apparently) can not be an alias for a filename so that you can reference it later. Is there a way to achieve this?   NOTE: I have a large variety of files and a large variety of different commands I want to run, so creating functions or aliasses for all of those different options will not be my preferred solution.