LINUX , UNIX , BASH AND CYGWIN TIPS AND TRICKS
This document contains linux unix bash cygwin related code snippets
This section contains tips and tricks on files and dirs management.
how-to create a symlink
# START === create symlink export link_path=/vagrant export target_path=/mnt/hgfs/vagrant mkdir -p `dirname $link_path` unlink $link_path ln -s "$target_path" "$link_path" ls -la $link_path; # STOP === create symlink
1. Select the cells.
2. Ctrl + H to present the find and replace dialog
3. For search: press the Alt num and from the Num keyboard type : 013 or 011
4. For replace: type the char to replace with
5. Replace all the occurrencies by : Alt + A
2. Ctrl + H to present the find and replace dialog
3. For search: press the Alt num and from the Num keyboard type : 013 or 011
4. For replace: type the char to replace with
5. Replace all the occurrencies by : Alt + A
In order to search and replace strings in the file and dir contents perform the copy paste the following code in your bash shell terminal.
# START -- how-to search and replace recursively export dir=/var/aktia/3rdparty/docs/docx; export to_search="emric" export to_replace="t24" #-- search and replace in file contents find "$dir/" -type f -exec perl -pi -e "s#$to_search#$to_replace#g" {} \; find "$dir/" -type f -name '*.bak' | xargs rm -f # STOP -- how-to rename files recursively
In order to search and replace strings in the file and dir paths perform the copy paste the following code in your bash shell terminal.
# START -- how-to search and replace recursively export dir=/var/aktia/3rdparty/docs/docx; export to_search="emric" export to_replace="t24" #-- search and replace in file names find "$dir/" -type d |\ perl -nle '$o=$_;s#'"$to_search"'#'"$to_replace"'#g;$n=$_;`mkdir -p $n` ;' find "$dir/" -type f |\ perl -nle '$o=$_;s#'"$to_search"'#'"$to_replace"'#g;$n=$_;rename($o,$n) unless -e $n ;'
Bunch of commands for packing and unpacking on Linux
Run the followint commands in the bash shell:
export dir=<> cd $dir # upack !!! gzip -dc *.tar.gz | tar xvf -
how-to unpack a tar package
#how-to unpack tar file tar xvf $file
how-to check which ports are listening + others netstta
# which processes are listening on my system netstat --tcp --listening --programs netstat --tcp netstat --route
Start on the client , check the comments when to move on the server.
# START === how-to implement public private key ( pkk ) authentication # create pub priv keys on server # START copy ssh-keygen -t rsa # copy the rsa pub key to the ssh server scp ~/.ssh/id_rsa.pub $ssh_user@$ssh_server:/home/$ssh_user/ # STOP copy # Hit enter twice # START copy cat id_rsa.pub >> ~/.ssh/authorized_keys cat ~/.ssh/authorized_keys chmod -v 0700 ~/.ssh chmod -v 0600 ~/.ssh/authorized_keys chmod -v 0600 ~/.ssh/id_rsa chmod -v 0644 ~/.ssh/id_rsa.pub find ~/.ssh -exec stat -c "%U:%G %a %n" {} \; rm -fv ~/id_rsa.pub # STOP COPY # START copy ssh-keygen -t dsa # STOP copy # Hit enter twice # START copy cat id_dsa.pub >> ~/.ssh/authorized_keys cat ~/.ssh/authorized_keys chmod -v 0700 ~/.ssh chmod -v 0600 ~/.ssh/authorized_keys chmod -v 0600 ~/.ssh/id_dsa chmod -v 0644 ~/.ssh/id_dsa.pub find ~/.ssh -exec stat -c "%U:%G %a %n" {} \; rm -fv ~/id_dsa.pub # STOP COPY # STOP === how-to implement public private key authentication
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!