Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

You should use open with the w+ mode:
***
file = open('myfile.dat', 'w+')
***
3 years ago
Using tee instead of cat

Not exactly as an answer to the original question, but I wanted to share this anyway: I had the need to create a config file in a directory that required root rights.

The following does not work for that case:
***
$ sudo cat </etc/somedir/foo.conf
# my config file
foo=bar
EOF
***
because the redirection is handled outside of the sudo context.

I ended up using this instead:
***
$ sudo tee </dev/null
# my config file
foo=bar
EOF
***
3 years ago
This is probably caused by cp being already aliased to something like cp -i. Calling cp directly should work:
***
/bin/cp -rf /zzz/zzz/* /xxx/xxx
***
Another way to get around this is to use the yes command:
***
yes | cp -rf /zzz/zzz/* /xxx/xxx
***
3 years ago
If you want all groups known to the system, I would recommend using getent group instead of parsing /etc/group:
***
getent group
***
The reason is that on networked systems, groups may not only read from /etc/group file, but also obtained through LDAP or Yellow Pages (the list of known groups comes from the local group file plus groups received via LDAP or YP in these cases).

If you want just the group names you can use:
***
getent group | cut -d: -f1
***
3 years ago
If you are going for a console command it would be:

chmod -R 777 /www/store. The -R (or --recursive) options make it recursive.

Or if you want to make all the files in the current directory have all permissions type:

chmod -R 777 ./
3 years ago
To start the shell-script 'file.sh':
***
sh file.sh

bash file.sh
***
Another option is set executable permission using chmod command:
***
chmod +x file.sh
***
Now run .sh file as follows:

./file.sh
3 years ago
If your library name is say libxyz.so and it is located on path say:
***
/home/user/myDir
***
then to link it to your program:
***
g++ -L/home/user/myDir -lxyz myprog.cpp -o myprog
***
3 years ago
Get the path of running Apache
***
$ ps -ef | grep apache
apache 12846 14590 0 Oct20 ? 00:00:00 /usr/sbin/apache2
***
Append -V argument to the path
***
$ /usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
***
3 years ago
General way:
***
export http_proxy=
***
Then you can connect through proxy from (many) application.

And, as per comment below, for https:
***
export https_proxy=/
***
3 years ago
Depending on what you want the file to contain:

touch /path/to/file for an empty file
somecommand > /path/to/file for a file containing the output of some command.
***
eg: grep --help > randomtext.txt
echo "This is some text" > randomtext.txt
***
nano /path/to/file or vi /path/to/file (or any other editor emacs,gedit etc)
It either opens the existing one for editing or creates & opens the empty file to enter, if it doesn't exist
3 years ago
With jQuery 1.6 and above you should use:
***
$("a").prop("href", "sample url")
***
The difference between prop and attr is that attr grabs the HTML attribute whereas prop grabs the DOM property.
3 years ago
With jQuery 1.6 and above you should use:
***
$("a").prop("href", "sample url")
***
The difference between prop and attr is that attr grabs the HTML attribute whereas prop grabs the DOM property.
3 years ago