8th June 2009
Found here.
Recursively set directories only to drwx-rx-rx (755):
find . -type d -exec chmod 755 {} \;
Recursively set files only to rwx-r-r (644):
find . -type f -exec chmod 644 {} \;
Recursively remove carriage returns (^M) from the end of all *.php files:
find . -type f -name “*.php” -exec /home/user/dos2unix.sh {} \;
In all these cases, {} is replaced with the filename/directory find has found matching your parameters; \; at the end just stops exec processing.
Posted in *nix, how-to, Links, Notepad | No Comments »
7th May 2009
MC is a console file manager. It supports FTP connections, and in my experience is faster in FTP than both Krusader and Gnome Commander.
However, the default FTP connection format string [username[:password]@]hostname has a drawback of not allowing the use of usernames with ‘@’-symbol in them – which is very common for virtual hostings.
One of the solutions is (done in your home directory):
- if there is no .netrc file in your home directory — touch .netrc && chmod 600 .netrc
- mcedit .netrc (or use vi, nano, or any other editor you prefer)
- add the following line to the file (replace all-caps words with your actual credentials): machine HOSTNAME login USER@HOSTNAME password PASSWORD
Now, start MC, choose FTP connect, and enter only the hostname. You will be automatically logged in to the remote FTP.
This will also work for console ftp clients like lftp.
Posted in *nix, how-to | 1 Comment »
16th April 2009
Connecting remotely via ssh to my Debian box at work, I needed to mount a CIFS (samba) share, but didn’t remember server name (or IP) and share name.
At least two convenient utilities are available in Debian Lenny for non-X Samba browsing.
smbtree (part of smbclient package) will list all visible workgroups, their servers, and share names of those servers – including “hidden” shares like C$, IPC$, ADMIN$, print$. Very handy and greppable!
samba-commander (smbc package) is a ncurses samba browser with “find file” functionality.
Posted in *nix, Software | No Comments »
30th March 2009
Imagine you have some styles.css transferred from Win machine to Linux via FTP in binary mode instead of ASCII mode; then
cat styles.css | tr -d "\r" > styles-nocarriage.css
will create styles-nocarriage.css with ^M’s removed.
Alternative syntax:
tr -d "\r" < styles.css > styles-nocarriage.css
Most editors have global replace features which allow to get rid of control characters using regular expressions (exact instructions are editor-specific).
For multiple files, try this:
for f
do
mv $f ${f}~ && tr -d "\r" <${f}~ >$f
rm ${f}~
done
Save this shell script as a file (e.g. dos2unix.sh), then do ./dos2unix.sh . This script accepts wildcards (e.g. ./dos2unix.sh *.php), so be careful!
Posted in *nix, how-to, Notepad | 3 Comments »
2nd March 2009
I assume you already have configured and working desktop environment, but want to improve performance.
First of all, sudo aptitude install mesa-utils. Then run in a Terminal/Konsole glxgears, and wait for ~15 seconds; if your FPS is ~400 or less, then you do have sluggish video performance (usually manifesting itself as slow scrolling in Firefox/Iceweasel, slow window switching/minimziing/maximizing etc).
After reading through several forums and bug reports and blog posts, I’ve ended with the following modifications to my /etc/X11/xorg.conf:
Read the rest of this entry »
Posted in *nix, Hardware, how-to | 5 Comments »
26th February 2009
(…)
it is a very useful tool for performing installations if you’ve got something like a LiveCD which supports your hardware.
(…)
Installing new Debian systems with debootstrap, and also as a debootstrap PDF (with comments).
Posted in *nix, Links | No Comments »
20th February 2009
I assume that you already have your gitosis-admin repository working (this is described elsewhere).
- cd gitosis-admin && git pull – enter your gitosis administrative repository and ensure it is up-to-date
- $EDITOR gitosis.conf
- add [group newreponame] section (newreponame is the name of your new repository being added); add yourself with members = yourlogin@yourhost line; also add writable = newreponame line:
[group newreponame]
members = yourlogin@yourhost
writable = newreponame
- based on my assumption of a correctly setup gitosis-admin repository, you should already have the appropriate public key in the keydir directory, but if not – copy your user’s ssh public key to keydir in the form of yourlogin@yourhostname.pub, then do git add keydir/yourlogin@yourhostname.pub
- git commit -am ‘new repository: newreponame’; git push;
- now that you have the new repo permissions configured, let’s actually create it. Navigate to the directory holding the files of your project (e.g. cd ~/newreponame), and do git init; git add . – this initializes empty git repository, and then adds all the files to it. If you have no files – you can skip the ‘git add .’ command, as it will do nothing for you.
- git commit -m ‘initial commit’. If you had no files added to the commit, git will complain that it cannot create an empty commit. In this case use the command git commit ––allow-empty -m ‘initial commit’
- git remote add origin ssh://gitosis@yourGitosisServerName/newreponame.git
- git push ––all
- final thing: git config ––add branch.master.remote origin && git config ––add branch.master.merge refs/heads/master; alternatively, cd .git && $EDITOR config, and then add these lines:
[branch "master"]
remote = origin
merge = refs/heads/master
Without these lines, you won’t be able to git pull.
Posted in *nix, how-to, Software | 16 Comments »