I am trying to use the rcs command to break a lock on a file but whenever I input on ubuntu:
rcs -u motd
it says:
rcs: RCS/motd,v: no such file or directory.
The file is there because I can use the cat command and edit it using vi.
Try rlog motd, which should give you information from the file RCS/motd,v . If that also gives you "no such file or directory", then it's the file motd,v in the subdirectory RCS, which doesn't exist or you can't access.
Related
I am trying to compare two files one local and other one on remote. I used
meld a.txt user#host:/home/user/john/b.txt
This was not possible because file could not be detected. However, I could copy the same file from the same location to local via scp and do the comparison afterwards. How to access the file directly on cluster for example like:
vim user#host:/home/user/john/b.txt
In bash, you can create a file from a process with <(...):
meld a.txt <(ssh user#host cat /path/to/file/b.txt)
If you want to modify the remote file, you'll have to use some mounting.
One way to do it is to use sshfs
# sshfs setup
mkdir ~/remote
sshfs user#host:/path/to/file ~/remote
# meld invocation
meld a.txt ~/remote/b.txt
Check the path in your example, I think it's incorrect. Try directly:
vim john#server:b.text
That should work.
Try save the remote file to your linux system and simply use diff -y file1 file2 command. You will see the diff between.
diffutils - packagre required for it
Create a script that will open a file for editing
1.If no argument is
given it will ask the user for a file name otherwise, it will open a file for
editing.
If the file already
exist it will be opened for editing.
If a file does not exist
it will open a file with the following settings
#!/bin/bash already
written on it
default permissions will be updated to –rwx------
Assuming the editor is vi, you don't need a script. Just vi filename will do as you want. Then set umask to set files creation permission as you require.
However if you really want to script this:
input_file=${1}
## Check file exists
if [ ! -f ${input_file} ]
then
## Doesnt exist - create empty file and set permission
> ${input_file}
chmod 700 ${input_file}
fi
## Edit the file
vi ${input_file}
I have a file named test:
[test#mypc ~]$ ls -i
4982967 test
Then I use vim to change its content and enter :w to save it.
It now has a different inode:
[test#mypc ~]$ ls -i
4982968 test
That means it's a different file already, why would vim save it to another file as I use :w to save to the original one?
You see, echo to a file will not change the inode, which is expected:
[test#mypc ~]$ echo v >> test
[test#mypc ~]$ ls -i
4982968 test
It is trying to protect you from disk and os problems. It writes out a complete copy of the file, and when it is satisfied this has finished properly, renames this file to the required filename. Hence, new inode number.
If there were a crash during the save process, the original file would remain untouched, possibly saving you from losing the file completely.
I have a shell script (my.sh) which imports another file (myfile.env). The name of myfile.env is passed as an argument to my.sh. It works well as root and I want the ability to run it to be given for other users via sudo.
myfile.env
some shell scripts........
my.sh
ENVFILE="$1"
if [ -e $ENVFILE ] ; then
. $ENVFILE
fi
I call the my.sh as
sudo /abc/def/my.sh myfile.sh
sudoers file goes as below
Cmnd_Alias MYSUDO = /abc/def/my.sh, /bin/bash
%mygroup ALL = MUSUDO
Unfortunately this results with an error in the 3rd line in the my.sh code above. It says
.: myfile.env: cannot open [No such file or directory]
its funny that i get this error after a check on file exist returned true.
sudo -s and -E options didn't help (don't know whether I used them correctly)
Can someone please help me to resolve this? I am using CeNT OS 6.5
use sudo /abc/def/my.sh /absolute/path/to/myfile.env
If myfile.sh is supposed to be in the same dir as my.sh, then my.sh can do this:
ENVFILE=$(dirname "$0")/"$1"
Finally I was able to get it done. It was setting in the sudoer file to get the directories (the folder in with those files were) into safe path list.
All I had to do was,
run visudo
and append the two dolders (where the files are) into
Defaults secure_path list
That will add those directories into the PATH when a user get elevated rights.
https://askubuntu.com/questions/128413/setting-the-path-so-it-applies-to-all-users-including-root-sudo
When I use zipcloak to encrypt an existed zip file, I got an error like this:
zipcloak error: Permission denied
zipcloak error: Temporary file failure (ziC8mO6F)
The command I executed:
/usr/local/bin/zipcloak /Library/WebServer/foo.zip
I'm sure I've set the permission of /Library/WebServer to 777, but it seems like zipcloak create the temporary file in a different place.
By the way when I specify the temporary path by -b option of zipcloak, it's worked.
/usr/local/bin/zipcloak -b /Library/WebServer/ /Library/WebServer/foo.zip
The -b option:
-b Use the specified path for the temporary zip archive
It tries to open a temporary file in the current directory.