Untar file in Ubuntu 16.04 - ubuntu-16.04

I want to untar a file in Ubuntu but as I enter this command
tar xvf filename.tgz
I receive the following errors:
tar: filename.tgz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
How can I solve this?

Use cd to go into the directory on which the file.tgz file is located and then run the below command to extract its content.
tar -zxvf file.tgz

Related

tar: Error opening archive: Failed to open 'wekaUT.tar.gz' in Command Line Windows 10

I want to extract a tar file that I obtained at tar.gz file. However, when I try: tar -xzvf wekaUT.tar.gz
I get the following error:
tar: Error opening archive: Failed to open 'wekaUT.tar.gz'
I see the file in my directory as wekaUT.tar.gz.
Any help would be much appreciated.
Just commenting here as I ran into the same issue. In windows "tar xfv .tar.gz" should work if you open the command prompt as administrator.
In my case, I was building the file to untar dynamically using a variable like
tar -xzvf "$SOME_TEMP_DIR/a_cool_file.tar.gz"
And encountered this error because of the quotes. If I updated it to:
tar -xzvf $SOME_TEMP_DIR/a_cool_file.tar.gz
It worked :)
In windows compand promt use quotation marks ("") when specifying the path. It will work properly
Exaple : tar -xvzf "C:/PATH/TO/FILE/FILE-NAME.tar.gz" -C "C:/PATH/TO/FOLDER/EXTRACTION"
tar -xvzf "C:/PATH/TO/FILE/FILE-NAME.tar.gz"

I can't locate my pid file to delete it so that I can start postgresql again?

Long story short my db didn't get shutdown correctly and I am trying to get it back up and running
I have run a
sudo find / -name postmaster.pid
to locate the file.
but when I run
sudo rm /Users/cward/Library/Application Support/Postgres/var-10/postmaster.pid
I get the following
rm: /Users/cward/Library/Application: No such file or directory
rm: Support/Postgres/var-10/postmaster.pid: No such file or directory
Your folder name contain space. You should quote the full path like this:
sudo rm "/Users/cward/Library/Application Support/Postgres/var-10/postmaster.pid"

Cannot unpack .tgz mongodb distribution on OSX

I grab the tgz file via
curl -O https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-2.6.12.tgz
yes I want mongodb version 2.6.12... :(
and I try to unzip it using:
tar -xvzf mongodb-osx-ssl-x86_64-2.6.12.tgz
but I get:
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
anybody know what might be wrong?
The file didn't download property, so even though it was a .tgz file on the filesystem it was incomplete or corrupted. To get a proper download I had to drop the ssl
before:
curl -O https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-2.6.12.tgz
after:
curl -O https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.6.12.tgz
then unpacking with tar worked. √

how to exclude snapshots while running tar in Solaris

I'm trying to take a tar of the '/home/store/' directory content.
tar cvf store.tar /home/store/
While doing so, I can see that the .snapshot directories are also getting included. My understanding is that snapshots are kind of backups. Can I skip this? If possible, how? Tried excluding a test directory using the below command ran from /home/store/
tar cvfX store.tar <(echo /home/store/test) /home/store/
But this is not excluding the test directory from the tar created.
Also, tried this
tar cvf store.tar /home/store/ --exclude-file=exclude.txt
Output:
a /home/store// 0K
a /home/store//.profile 1K
a /home/store//local.profile 1K
a /home/store//.vas_logon_server 1K
a /home/store//.vas_disauthcc_611400381 1K
a /home/store//.bash_history 7K
a /home/store//test/ 0K
a /home/store//test/1.txt 1K
a /home/store//test/migrate-perf3.txt 3958K
a /home/store//test.txt 1K
a /home/store//exclude.txt 1K
a /home/store//.snapshot/hourly.0/d2/dd/d5d/f82-1 59K
a /home/store//.snapshot/hourly.0/d2/dd/d5d/f83-1 58K
.....
tar: --exclude-file=exclude.txt: No such file or directory
/home/store/exclude.txt has the entry 'test'. Tried entering the following as well and got same error.
/home/store/test/
/home/store/test/1.txt
When I gave the full path to 'exclude.txt' like this
`tar cvf store.tar /home/store/ --exclude-file=/home/store/exclude.txt`
it's giving the below error
tar: can't change directories to --exclude-file=/home/store: No such file or directory
tar -h
Usage: tar {c|r|t|u|x}[BDeEFhilmnopPqTvw#[0-7]][bfk][X...] [blocksize] [tarfile] [size] [exclude-file...] {file | -I include-file | -C directory file}...
Thanks well in advance!
Van Peer
Try to do so:
tar cvfX /var/tmp/src.tar /var/tmp/excl.txt /var/tmp/src/
Your exclude file should contain path:
/home/store//.snapshot
Best practice not to use full path of your tar dir, because in future you can overwite your /etc , when extract tar archive from /var/tmp, for example.
For example:
sudo tar -zcvpf /backup/farm-backup-$(date +%d-%m-%Y).tar.gz --exclude ".snapshots" --exclude ".cache" farm
Did not use a backslash in the command ie:/farm for the directory. Execute the tar command from the /home directory to back up "farm" user.
for making a backup in the root /backup directory.
OS: OpenSuse 15.1

Windows command line tar "cannot connect to d: resolve failed" with Chef Knife

Using Windows Command line with cygwin, chef and ruby installed. When trying
knife cookbook site install mysql
returns the following error
Begin output of tar zxvf D:/path/to/chef-repo/cookbooks/mysql.tar.gz
STDOUT:
STDERR: tar<child>: Cannot connect to D: resolve failed
gzip: stdin: undexpected end of file
tar: Child returned status 128
tar: Error is not recoverable: exiting now</code>
How can I remedy this issue? I can manually unzip using
tar zxvf mysql.tar.gz
but this is less than ideal. I believe this has to do with the colon in filename but how can I change that in the knife or chef preferences?
The reason is that tar interprets colons (:) in file names as meaning it is a file on another machine. You can disable this behavior by using the flag --force-local.
This is from an answer from here.
I don't know a complete answer but have been seeing this on Linux machines lately:
$ date > today
$ tar -czf - today > to:day.tgz
$ tar -tzf to:day.tgz
ssh: connect to host to port 22: Connection refused
tar (child): to\:day.tgz: Cannot open: Input/output error
tar (child): Error is not recoverable: exiting now
gzip: stdin: unexpected end of file
tar: Child returned status 2
tar: Error is not recoverable: exiting now
$ tar -tzf - < to:day.tgz
today
$
It appears that tar wants to do some sort of remote file processing because of the colon in the file name and you can fake it out by using some form of redirection or piping - for both reading and writing a tarball. I would still like to find an option or something to tell tar not to behave this way.
Will the tar command work if ran from cmd? Also what if the output is to a local drive. Something else try this,
tar zxvf "D:/path/to/chef-repo/cookbooks/mysql.tar.gz"