https://piazza-resources.s3.amazonaws.com/j6zdjr2o14g248/j7hl17d3fku6te/lab1.pdf?AWSAccessKeyId=AKIAIEDNRLJ4AZKBW6HA&Expires=1505775332&Signature=0n1JbqGf5F%2BRtA%2FFmqEgQcdi6iQ%3D
I don't know how to "4. Commit this new file to your repository" (step 3 part 4)
Below is everything I did up to step 3 part 4
>>> cd /cmshome/myutorid/cscb07f17_space
>>> mkdir ./lab1
>>> cd lab1
>>> mkdir ./.myrepo
>>> svnadmin create ./.myrepo
>>> pwd
/cmshome/myutorid/cscb07f17_space/lab1
>>> mkdir ./myCode1
>>> svn co file:///cmshome/myutorid/cscb07f17_space/lab1/.myrepo myCode1
Checked out revision 0.
>>> cd myCode1
>>> ls -al
total 0
drwx------ 1 myutorid cmsusers 76 Sep 18 16:01 .
drwx------ 1 myutorid cmsusers 104 Sep 18 16:00 ..
drwx------ 1 myutorid cmsusers 204 Sep 18 16:01 .svn
>>> ls -a
. .. .svn
>>> touch A.txt
>>> pico A.txt
Use "fg" to return to nano.
[1]+ Stopped pico A.txt
Could someone tell me how to commit A.txt into the repository? Does it matter what directory im stationed in?
You will need to place the file under revision control, for example:
svn add A.txt
Then you commit changes to the repository using commit, for example:
svn commit A.txt
The examples above are executed in the same directory as the file, but svn will deduce the location of the repository as long as commands are executed within the working copy (anywhere within myCode1).
The commit command requires an editor to be configured, alternatively you will need to use the -m option to provide a commit message.
By the way, [1]+ Stopped pico A.txt means pico is still running and the file has not necessarily been saved and closed. Is that what you intended?
See the online version of the manual for more.
Related
When I open terminal, my working directory is a/b/c/
and my shell script is placed under a/b/d/e/f/ which gets triggered through Autosys.
I want to change my working directory from a/b/c/ to a/b/d/e/f/ using relative path.
Currently I'm hard coding cd a/b/d/e/f/. I don't want to do it anymore. Could you please let me know how can this be achieved.
cd ../d/e/f/
The trick being the .. which is the "parent directory" of the one you're in
You can see a reference to it (including its permissions) if you use ls -a or more completely
$ ls -lhaF
total 0
drwxr-xr-x 20 user group xxB Jun 15 00:00 ./
drwxr-xr-x 3 user group xxB Jun 15 00:00 ../
-rw-r--r-- 1 user group xxB Jun 15 00:00 e/
When executing a Python 3 script in a symbolic directory, I want to get the non-dereferenced path of the current directory. However, the default behavior of pathlib returns the derefenced path:
$ mkdir test1
$ ln -s test1 test2
$ cd test2
$ pwd
/home/myuser/test2
$ ipython3
Python 3.7.0 (default, Oct 9 2018, 10:31:47)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from pathlib import Path
In [2]: str(Path.cwd())
/home/myuser/test1
The behavior I want is to get "/home/myuser/test2" as that's where the 'script' (interpreter in this case) was executed from, preferably using pathlib.
Use os.getenv('PWD'):
Directories:
$ ls -l
total 1
drwxr-xr-x+ 1 cody agroup 0 Dec 11 15:23 dir1
lrwxrwxrwx 1 cody agroup 4 Dec 11 15:23 dir2 -> dir1
Result from dir2:
>>> str(Path.cwd())
'/home/cody/so/dir1'
>>> os.getenv('PWD')
'/home/cody/so/dir2'
fuser can show you ONLY if original file is in use.
fuser DOESN'T SHOW YOU IF SYMLINK IS IN USE which calls original file. That's the issue. You don't know if symlink unused and can be removed.
I have started two processes (24261 opened original file and 24262 opened symlink) :
root#server DEV # ls -l /lib64/libgcc_s-4.4.7-20120601.so.1
-rwxr-xr-x 1 root root 93320 Sep 1 2014 /lib64/libgcc_s-4.4.7-20120601.so.1
root#server DEV # ls -l /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so
lrwxrwxrwx. 1 root root 20 Oct 19 2015 /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so -> /lib64/libgcc_s.so.1
root#server DEV #
root#server DEV # tail -f /lib64/libgcc_s.so.1 &
[1] 24261
root#server DEV #
root#server DEV # cd /usr/lib/gcc/x86_64-redhat-linux/4.4.4
root#server DEV # tail -f libgcc_s.so &
[2] 24262
root#server DEV #
root#server DEV # ps -ef | grep tail
root 24261 3265 0 13:39 pts/1 00:00:00 tail -f /lib64/libgcc_s.so.1
root 24262 3265 0 13:39 pts/1 00:00:00 tail -f libgcc_s.so
root 24492 3265 0 13:40 pts/1 00:00:00 grep tail
root#server DEV #
In both cases fuser tells that symlink and original file is in use (there are two processes for each command):
root#server DEV # fuser /lib64/libgcc_s.so.1
/lib64/libgcc_s.so.1: 24261 24262
root#server DEV # fuser /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so: 24261 24262
root#server DEV #
But we know that symlink was not used for the first process. It can be even removed and will not affect first process.
Let's say I want to remove 'gcc' package if the package is not in use.
Original file comes from 'libgcc' package.
root#server DEV # rpm -qf /lib64/libgcc_s.so.1
libgcc-4.4.7-11.el6.x86_64
Symlink comes from 'gcc' package:
root#server DEV # rpm -qf /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so
gcc-4.4.7-11.el6.x86_64
If I will remove 'gcc' package which contains only symlink, I will affect second process! How I can see if symlink is unused?
In my case 'ps -ef' shows that I used command:
root 24262 3265 0 13:39 pts/1 00:00:00 tail -f libgcc_s.so
So ps cannot even tell you that symlink was used.
Any Linux guru?
EDITED:
There is partial solution checking cwd - current working directory:
root#server DEV # ls -l /proc/24262/cwd
lrwxrwxrwx 1 root root 0 Jun 20 13:57 /proc/24262/cwd -> /usr/lib/gcc/x86_64-redhat-linux/4.4.4
root#server DEV #
So from here you see the path "/usr/lib/gcc/x86_64-redhat-linux/4.4.4" and you can get file name from ps.
This doesn't work if you do:
root#server DEV # cd /root
root#server DEV # cat script.sh
/usr/bin/tail -f /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so
root#server DEV #
root#server DEV # nohup ./script.sh &
[2] 26713
root#server DEV #
root#server DEV # ls -l /proc/26713/cwd
lrwxrwxrwx 1 root root 0 Jun 20 14:32 /proc/26713/cwd -> /root
It shows cwd for /root, but symlink is inside the script/program. So then you need to check ps chill process for /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so.
root#server DEV # ps -ef | grep 26713
root 26713 3265 0 14:32 pts/1 00:00:00 /bin/sh ./script.sh
root 26714 26713 0 14:32 pts/1 00:00:00 /usr/bin/tail -f /usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so
root 26780 3265 0 14:38 pts/1 00:00:00 grep 26713
root#server DEV #
This is very confusing when you want to automate package removal (if the package is not in use).
It will be great if someone can see simpler way of this. Also if someone can confirm the accuracy of using cwd and ps child processes for symlink in use detection.
What will happen if script.sh would be binary file? Will I still able to see full symlink path in 'ps' or cwd?
Symlinks are not usual files: they cannot be opened with open() like regular files or directories. Symlink actually is just a constant string, which is automatically interpreted internally during path resolution.
Because of that symlinks are not "used" in the sence of utilities like fuser. When you call fuser for symlink, it actually shows info about file pointed by the link.
If by "in use" you mean "one or more programs is using the link as its path name for the file", then there is no way to tell. It could have been used yesterday, and it might be used tomorrow. Unix is designed so that, unless you are specifically using tools designed for that specific purpose, a symlink looks just like the file it points to. Programs like fuser or lsof will just go right through the links without even telling you it's a link.
If by "in use" you mean "points to a valid file", then there are ways to tell. The simplest being ls -L
$ ls -l foo
/bin/ls: cannot access foo: No such file or directory
$ ls -l g
lrwxrwxrwx 1 hymie users 3 2016-06-20 10:09 g -> foo
$ ls -lL g
/bin/ls: cannot access g: No such file or directory
Unfortunately, Linux kernel is designed to assign original file from the symlink in the start up phase. So when the process is running there is no possibility to check if file called directly or through symlink.
All you can do is to check what was current working directory ls -l /proc/<process_id>/cwd, command line arguments strings /proc/<process_id>/cmdline, what user started the process ps -ef | grep <process_id> then you can check user startup scripts and $PATH, ldd can show you which libraries are called from particular library. If you want to restart the process to see if symlink called then strace is your friend.
The premise of this question (identifying unused packages with fuser / lsof) is fundamentally flawed:
Not every file your system needs to work properly will referenced by an open file descriptor at any random time.
For example, you would have a bad time if you removed /bin/systemctl (since things like /sbin/shutdown are symlinks to it), but lsof shows nothing using it.
It's easy to come up with many more examples, like /bin/grep on my system. It's used all over the place in shell scripts, but I don't happen to have any long-running instances of it.
i create backup folder in ftp server , and send all my .tar.gz file into /backup folder
using (put file.tar.gz backup)
while i retrieve backup,, i get backup folder as backup files. ,, how to convert the file to folder ..
ftp server
ls
227 Entering Passive Mode (10,21,131,105,76,56)
150 Accepted data connection
drwxr-xr-x 6 100 ftpgroup 7 Oct 20 19:57 .
drwxr-xr-x 6 100 ftpgroup 7 Oct 20 19:57 ..
-r-------- 1 100 ftpgroup 84 Oct 21 11:15 .banner
drwxrwxrwx 3 100 ftpgroup 4 Oct 20 18:28 backup
drwxrwxrwx 2 100 ftpgroup 3 Oct 20 19:45 dailybackup
drwxrwxr-x 2 100 ftpgroup 3 Oct 20 19:57 hi5songs
drwxrwxr-x 2 100 ftpgroup 3 Oct 20 19:49 whole
226-Options: -a -l
226 7 matches total
i tried :
ftp> mget backup``
mget .? y
227 Entering Passive Mode (10,21,131,105,62,8)
550 I can only retrieve regular files
mget ..? y
Warning: embedded .. in .. (changing to !!)
227 Entering Passive Mode (10,21,131,105,46,39)
550 Can't open !!: No such file or directory
mget backup? y
227 Entering Passive Mode (10,21,131,105,72,24)
550 I can only retrieve regular files
mget cpanelbackup? y
227 Entering Passive Mode (10,21,131,105,73,69)
550 Can't open cpanelbackup: No such file or directory
while
i use (get backup home)
it successfully retrieve but as files shown below
server:
'root#azar [/home]# ls
./ backup.2* .cpan/ dailybackup hi5songs.4 oldeserver
../ backup.3* cPanelInstall/ hi5songs/ hi5songs.5 oldserver/
0_README_BEFORE_DELETING_VIRTFS backup.4* .cpanm/ hi5songs.1 home quota.user
backup/ backup.5* .cpcpan/ hi5songs.2 latest virtfs/
backup.1* .banner cpeasyapache/ hi5songs.3 lost+found/ whole'
i got that backup with green color executable file like backup.1* ( note: i cant open those file and extract those files) what to do
how to get my .tar.gz file back
please guide me,,
advance thanks,,
Updated Answer
If you want to get all files from /some/place on your server, to /home/here on your local machine, you would either do this:
cd /home/here # change directory before starting FTP
ftp server ... # connect
cd /some/place # go to desired folder on server
bi # ensure no funny business with line-endings
mget * # get all files
or you can change directory locally, within FTP like this:
ftp server ... # connect
cd /some/place # go to desired folder on server
lcd /home/here # LOCALLY change directory to where you want the files to 'land'
bi # ensure no funny business
mget * # get all files
Original Answer
I cannot understand your question at all, but you are doing some things wrong.
You cannot use GET or MGET to get a folder (directory) like you are trying to do with mget backup. You can only GET a file. Now your file may be a tar-file with more than one file in it, but it is still a file.
If you are getting tar-files and binary files, you should use BINARY mode to ensure line-end characters that may occur in binary files are not translated between Windows and Unix line-endings. So, as a matter of course, you should issue BI command before you get files.
If you have several files in your backup directory, you should probably do cd backup then bi
then mget *
Can someone pls advise why I'm getting NO CHANGES found at the end.
Also, I'm getting an annoying message, "Username not specified in .hg/hgrc. Keyring will not be used."
Version tool: Hg latest version
Server: Linux
Workspace: ~/2012WS
LinuxServer123:~/2012WS # hg clone http://LinuxServer123/hg/GigaTest/
Username not specified in .hg/hgrc. Keyring will not be used.
http authorization required
realm: Mercurial Repositories
user: u123456
password:
destination directory: GigaTest
requesting all changes
adding changesets
adding manifests
adding file changes
added 14 changesets with 585 changes to 575 files (+1 heads)
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
LinuxServer123:~/2012WS #
LinuxServer123:~/2012WS # cd GigaTest/
LinuxServer123:~/2012WS/GigaTest # ls -tlr
total 12
-rw-r--r-- 1 root root 25 Jan 10 16:36 hello.py
-rw-r--r-- 1 root root 25 Jan 10 16:36 HELLO-UP.PY
drwxr-xr-x 4 root root 4096 Jan 10 16:36 .hg
LinuxServer123:~/2012WS/GigaTest # vi hello.py
LinuxServer123:~/2012WS/GigaTest # ls -l > new.txt
LinuxServer123:~/2012WS/GigaTest # hg add new.txt
LinuxServer123:~/2012WS/GigaTest #
LinuxServer123:~/2012WS/GigaTest #
LinuxServer123:~/2012WS/GigaTest # hg stat
M hello.py
A new.txt
LinuxServer123:~/2012WS/GigaTest #
LinuxServer123:~/2012WS/GigaTest # hg out
comparing with http://LinuxServer123/hg/GigaTest/
Username not specified in .hg/hgrc. Keyring will not be used.
http authorization required
realm: Mercurial Repositories
user: u123456
password:
searching for changes
no changes found
LinuxServer123:~/2012WS/GigaTest #
Thanks in advance.
You have to do hg commit first.
hg stat shows the changes made to the current working repository (since the last commit) and hg out shows the commits made to your repository that will be pushed out on hg push.
And the message "Username not specified in .hg/hgrc" means that your username is not specified in the .hg/hgrc file. Keyring is an extension I'm not familiar with; presumably it will take your username and do something with a key.