My understanding of tar command that it will override the content of the file if file exist. Otherwise it would keep as existing.
[root#something~]# ls -al /etc/init.d/
total XX
drwxr-xr-x. 2 root root 83 Jun 14 2018 .
drwxr-xr-x. 10 root root 127 Jun 6 2017 ..
-rwxr-xr-x. 1 root root 7293 Jan 2 2018 network
-rw-r--r--. 1 root root 1160 Feb 20 2018 README
[root#something~]# tar tvf /tmp/env_pkg_1.tar
drwxr-xr-x staff 0 2020-05-29 19:42 etc/
drwxr-xr-x user/staff 0 2020-05-29 18:04 etc/init.d/
-rw-r--r-- user/staff 3383 2020-05-29 18:04 etc/init.d/sshd
[root#something~]# cd /
[root#something /]# tar xf /tmp/env_pkg_1.tar
[root#something/]# ls -al /etc/init.d/
total 16
drwxr-xr-x 2 XXXXXX XXXXXX 18 May 29 18:04 .
drwxr-xr-x. 85 XXXXXX XXXXXX 8192 May 29 19:42 ..
-rw-r--r-- 1 XXXXXX XXXXXX 3383 May 29 18:04 sshd
I am not understand why tar is replacing the entire contents of /etc/init.d
Any inputs would be helpful ?
I belive that /etc/init.d is a link to /etc/rc.d/init.d.
When you untarred that file, it overwrote the link with a directory. All of your files are still in /etc/rc.d/init.d.
To fix your situation, remove /etc/init.d, relink it, and add a h to the tar command:
rm -rf /etc/init.d
cd /etc
ln -s ./rc.d/init.d
cd /
tar xhf /tmp/env_pkg_1.tar
You can use -k or --keep-old-files, so it does not touch any files that are already within the destination. Judging by your output in /etc/init.d/ you want to keep network and README and next to them extract sshd, so in your case, they do not overlap.
Alternatively --keep-newer-files will have tar replace files that are newer from the tar archive, than what's on the destination..
Related
xxxx:~/209_repo> ls -d */
drwx------ 4 xxxx student 4.0K Jan 16 12:44 a1/
drwx------ 2 xxxx student 4.0K Jan 11 14:06 t01/
drwx------ 2 xxxx student 4.0K Jan 17 06:50 t02/
This one works properly. But when I go to the subdirectory of 209_repo, it comes up with a path rather than a directory name.
xxxx:~/209_repo/t02> ls -d /student/xxxx/209_repo/*/
drwx------ 4 xxxx student 4.0K Jan 16 12:44 /student/xxxx/209_repo/a1/
drwx------ 2 xxxx student 4.0K Jan 11 14:06 /student/xxxx/209_repo/t01/
drwx------ 2 xxxx student 4.0K Jan 17 06:50 /student/xxxx/209_repo/t02/
Is there any way that I can get a1,t01,t01 only so that I don't have to extract them later on?
Or standard command to find the subtree of directories is also find . -type d and you can tune it and add some filtering.
I'm not aware of a ls option to do this.
You could try
(cd /student/xxxx/209_repo && ls -d */)
This starts a new subshell, due to (...) and in this subshell changes to the directory .../209_repo and then executes the ls.
After the command you are still in the directory you were before, as the change dir was only executed in the subshell.
Similar to #user7369280, but without subshell
cd /student/xxxx/209_repo/ && ls -d */ && cd -
EDIT
To mitigate failing ls command, and return to wd:
cd /student/xxxx/209_repo/ && ls -d */ && cd - || cd -
How do you uninstall xcode (7.4) ?
Most articles on the net mention a command
sudo /Developer/Library/uninstall-devtools --mode=all
but I dont have that program. Here's what I have
macimage:~ user1$ sudo ls -la /Library/Developer/
total 0
drwxr-xr-x 3 root admin 102 Aug 1 2014 .
drwxr-xr-x+ 67 root admin 2278 Sep 9 14:59 ..
drwxr-xr-x 4 root admin 136 Jul 24 2014 CommandLineTools
macimage:~ user1$
macimage:~ user1$ sudo ls -la /Developer/
ls: /Developer/: No such file or directory
macimage:~ user1$
I was looking for a way to cp a file and mod its perms to 400 at the same time... after some testing in the public_html folder...
public_html >> ls -lah
-rw-r--r-- 1 user user 0 Feb 27 14:21 a.txt
public_html >> cp a.txt{,.bak}
-rw-r--r-- 1 user user 0 Feb 27 14:21 a.txt
-rw-r--r-- 1 root root 0 Feb 27 14:23 a.txt.bak
perms are still the same (644) and although the file is owned by root, it is still readable via public_html
public_html >> cp a.txt{,.bak} && chmod 400 a.txt.bak
-rw-r--r-- 1 user user 653 Feb 27 14:26 a.txt
-r-------- 1 root root 653 Feb 27 14:30 a.txt.bak
this works but looking for something for a set newbs to use
awk/sed command possibly?
dont think I'm missing a cp flag that could modify the perms, wasn't seeing anything and don't think there are but wanted to pick the collective brain
thanks...
install(1) can both copy files and create directories, and set their permissions at the same time.
install -m 0400 foo bar/
I have a bash script which acts as a post-process script for utorrent-server that passes on variables to a media renamed called FileBot.
Script:
#!/bin/bash
TORRENT_NAME=$1
TORRENT_PATH=$2
TORRENT_LABEL=$3
TORRENT_KIND=$4
TORRENT_TITLE=$5
/usr/share/filebot/bin/filebot.sh -script fn:amc --output "/mnt/Storage/" \
--log-file "amc.log" --action move --conflict override -non-strict \
--def music=n subtitles=en artwork=n xbmc="192.168.0.123" deleteAfterExtract=y \
clean=y "ut_dir=$TORRENT_PATH" "ut_file=$TORRENT_NAME" "ut_kind=$TORRENT_KIND" \
"ut_title=$TORRENT_TITLE" "ut_label=$TORRENT_LABEL" "ut_state=5" "seriesFormat=TV \
Shows/{n}/Season {s.pad(2)}/{n} - {s00e00} - {t}" "movieFormat=Movies/{n} ({y})/{n} ({y})" \
&>> /home/xbmc/run.log
If i run this script manually, it works as intended, however when uTorrent executes it, it returns "No such file or directory." via stderr. I originally had uTorrent calling this script directly however I was having the same issue.
Does anyone know what could cause this?
UPDATE (Permissions for all directories/folders):
drwxr-xr-x 3 root root 4096 Nov 27 23:52 /home
drwxr-xr-x 20 xbmc xbmc 4096 Dec 15 21:46 /home/xbmc
drwxr-xr-x 10 root root 4096 Oct 17 06:51 /usr
drwxr-xr-x 218 root root 4096 Dec 13 15:32 /usr/share
drwxr-xr-x 3 root root 4096 Dec 15 15:55 /usr/share/filebot
drwxr-xr-x 2 root root 4096 Dec 15 18:56 /usr/share/filebot/bin
-rwxr-xr-x 1 xbmc xbmc 615 Dec 15 21:44 /home/xbmc/run.sh
-rwxr-xr-x 1 root root 552 Dec 15 18:56 /usr/share/filebot/bin/filebot.sh
Change the current working directory.
IF filebot.sh is the no-such-file, I suggest you to try with this:
chmod -R a+x /usr/share/filebot/bin/filebot.sh
IF it is your run.sh,
chmod -R a+x /home/xbmc/run.sh
You can try running filebot.sh as the owner. I think it worths a shot.
chown YOURUSERNAME /usr/share/filebot/bin/filebot.sh
chmod u+s /usr/share/filebot/bin/filebot.sh
What does the command cp $1/. $2 do? I know cp is used for copying from source(stored in variable $1) to destination(stored in variable $2). I am just confused with the /. used along with the variable. Can someone please help me understand this?
The command:
$ cp -R $1/. $2
copies contents of directory pointed by $1 to the directory $2.
Without -R switch this command would fail both when $1 is a file or directory.
In general, . points to the current directory. You can see that by comparing inode's shown by ls:
$ mkdir test
$ ls -ali
9525121 drwxr-xr-x 3 IU wheel 102 23 mar 12:31 .
771046 drwxrwxrwt 21 root wheel 714 23 mar 12:30 ..
9525312 drwxr-xr-x 2 IU wheel 68 23 mar 12:31 test
$ cd test
$ ls -ali
9525312 drwxr-xr-x 2 IU wheel 68 23 mar 12:31 .
9525121 drwxr-xr-x 3 IU wheel 102 23 mar 12:31 ..
Note that inode 9525312 points to test when viewed from the parent directory, and points to . when viewed from inside the test directory.