Three basic behaviors are possible when rsync encounters a symbolic
link in the source directory.
By default, symbolic links are not transferred at all. A message
"skipping non-regular" file is emitted for any symlinks that exist.
If --links is specified, then symlinks are recreated with the same tar-
get on the destination. Note that --archive implies --links.
If --copy-links is specified, then symlinks are "collapsed" by copying
their referent, rather than the symlink.
Rsync can also distinguish "safe" and "unsafe" symbolic links. An
example where this might be used is a web site mirror that wishes to
ensure that the rsync module that is copied does not include symbolic
links to /etc/passwd in the public section of the site. Using
--copy-unsafe-links will cause any links to be copied as the file they
point to on the destination. Using --safe-links will cause unsafe
links to be omitted altogether. (Note that you must specify --links
for --safe-links to have any effect.)
Symbolic links are considered unsafe if they are absolute symlinks
(start with /), empty, or if they contain enough ".." components to
ascend from the directory being copied.
Here's a summary of how the symlink options are interpreted. The list
is in order of precedence, so if your combination of options isn't men-
tioned, use the first line that is a complete subset of your options:
--copy-links
Turn all symlinks into normal files (leaving no symlinks for any
other options to affect).
--links --copy-unsafe-links
Turn all unsafe symlinks into files and duplicate all safe sym-
links.
--copy-unsafe-links
Turn all unsafe symlinks into files, noisily skip all safe sym-
links.
--links --safe-links
Duplicate safe symlinks and skip unsafe ones.
--links
Duplicate all symlinks.
Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts
Tuesday, June 14, 2016
rsync
rsync - how to suppress "skipping non-regular file" messages:-
Saturday, June 11, 2016
How to unzip/extract a .tar.gz file in linux?
Type
man tar for more information, but this command should do the trick:tar -xvzf community_images.tar.gz
To explain a little further, tar collected all the files into one package,
community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things.f: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file.z: tells tar to decompress the archive using gzipx: tar can collect files or extract them.xdoes the latter.v: makes tar talk a lot. Verbose output shows you all the files being extracted.
Copying Files Over SSH
Secure copy is a really useful command, and it’s really easy to use. The basic format of the command is as follows:
scp [options] original_file destination_file
The biggest kicker is how to format the remote part. When you address a remote file, you need to do it in the following manner:
user@server:path/to/file
The server can be a URL or an IP address. This is followed by a colon, then the path to the file or folder in question. Let’s look at an example.
scp –P 40050 Desktop/url.txt yatri@192.168.1.50:~/Desktop/url.txt
This command features the [-P] flag (note that it’s a capital P). This allows me to specify a port number instead of the default 22. This is necessary for me because of the way I’ve configured my system.
Friday, June 10, 2016
How to create an SSH shortcut
If you are constantly needing to SSH into multiple servers, it can real daunting to remember all the different usernames, hostnames, IP addresses, and even sometimes custom private keys to connect to them. It’s actually extremely easy to create command line shortcuts to solve this problem. There’s two major ways to do it, and we’ll discuss the pros and cons of each.
SSH on *NIX machines, such as Linux or Mac, have default shortcut functionality right out of the box. It’s very straight forward to setup, too. For those two reasons, this is my preferred way of setting up SSH shortcuts. The first step is to navigate to your .ssh folder:
cd ~/.ssh
Following this, you’ll need to create a file called
config. Here’s how to do it with Vim:
vim config
From here, you can now create shortcuts. You can specify the hostname, username, port, and the private key. For a full list of options, please visit the official docs. Here’s an example of how to structure the file:
Host scotch
HostName scotch.io
User nick
<br>
Host example2
HostName example.com
User root
<br>
Host example3
HostName 64.233.160.0
User userxyz123
Port 56000
<br>
Host amazon1
HostName ec2.amazon.com
User ec2-user
IdentityFile /path/to/special/privatekey/amazon.pem
Now, you can simply SSH into any of these servers with these simple commands:
ssh scotch
ssh example2
ssh example3
ssh amazon1
If this isn't working for you, trying changing the permissions of the config file like this:
chmod 600 ~/.ssh/config
#Method 2: Create aliases for your shell
This method involves creating an alias for your shell (or terminal). You can use this for creating any type of shortcut you want, but a lot of people use them for SSH shortcuts. To set this up, you'll need to navigate to your
.bash_aliases file (or some people do this in .bashrcor .bash_profile). The following command will create the .bash_aliases file if it doesn't exist or just edit it if it already does using Vim.
vim ~/.bash_aliases
Here you can add as many shortcuts as you want. Here's how to add the same SSH shortcuts from above:
alias scotch='ssh nick@scotch.io'
alias example2='ssh root@example.com'
alias example3='ssh userxyz123@64.233.160.0 -p 56000'
alias amazon1='ssh ec2-user@ec2.amazon.com -i /path/to/special/privatekey/amazon.pem'
After you add those and save the file, you'll need to "reboot" the aliases file with:
source ~/.bash_aliases
Once that is completed, you can now SSH into all of those same boxes by just typing the following:
scotch
example2
example3
amazon1
This method provides additional flexibility that the first method might not be able to provide, but it really comes down to a matter of preference for most use cases.
How to create an SSH shortcut
If you are constantly needing to SSH into multiple servers, it can real daunting to remember all the different usernames, hostnames, IP addresses, and even sometimes custom private keys to connect to them. It’s actually extremely easy to create command line shortcuts to solve this problem. There’s two major ways to do it, and we’ll discuss the pros and cons of each.
SSH on *NIX machines, such as Linux or Mac, have default shortcut functionality right out of the box. It’s very straight forward to setup, too. For those two reasons, this is my preferred way of setting up SSH shortcuts. The first step is to navigate to your .ssh folder:
cd ~/.ssh
Following this, you’ll need to create a file called
config. Here’s how to do it with Vim:
vim config
From here, you can now create shortcuts. You can specify the hostname, username, port, and the private key. For a full list of options, please visit the official docs. Here’s an example of how to structure the file:
Host scotch
HostName scotch.io
User nick
<br>
Host example2
HostName example.com
User root
<br>
Host example3
HostName 64.233.160.0
User userxyz123
Port 56000
<br>
Host amazon1
HostName ec2.amazon.com
User ec2-user
IdentityFile /path/to/special/privatekey/amazon.pem
Now, you can simply SSH into any of these servers with these simple commands:
ssh scotch
ssh example2
ssh example3
ssh amazon1
If this isn't working for you, trying changing the permissions of the config file like this:
chmod 600 ~/.ssh/config
#Method 2: Create aliases for your shell
This method involves creating an alias for your shell (or terminal). You can use this for creating any type of shortcut you want, but a lot of people use them for SSH shortcuts. To set this up, you'll need to navigate to your
.bash_aliases file (or some people do this in .bashrcor .bash_profile). The following command will create the .bash_aliases file if it doesn't exist or just edit it if it already does using Vim.
vim ~/.bash_aliases
Here you can add as many shortcuts as you want. Here's how to add the same SSH shortcuts from above:
alias scotch='ssh nick@scotch.io'
alias example2='ssh root@example.com'
alias example3='ssh userxyz123@64.233.160.0 -p 56000'
alias amazon1='ssh ec2-user@ec2.amazon.com -i /path/to/special/privatekey/amazon.pem'
After you add those and save the file, you'll need to "reboot" the aliases file with:
source ~/.bash_aliases
Once that is completed, you can now SSH into all of those same boxes by just typing the following:
scotch
example2
example3
amazon1
This method provides additional flexibility that the first method might not be able to provide, but it really comes down to a matter of preference for most use cases.
Tuesday, May 31, 2016
How to enable extensions in PHP 7
Lets see how to enable cURL extension in PHP7
When yo update ubuntu on 16.04 or latest version then php upgrade to 6 to 7.
Note: This guide is for those who have FULL access to the server, when system configuration can be changed. If you are using shared hosting, please contact your hosting provider.
Step 1: Check whether cURL extension is installed/enabled or not
To create a phpinfo file, open a plain text file, add the following lines, and save:
Filename: phpinfo.php
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Visit the page in your browser. If you uploaded it to your html directory, you should now visithttp://www.example.com/phpinfo.php, replacing example.com with your own domain name.
At this point, search for the keyword “curl” and if it does not appear on the page, the extension might not be installed/enabled. Please proceed to the next step.P.S: In this step, you are also able to locate where the “php.ini” configuration file is. Search for“Loaded Configuration File” and you might end up with something like:Step 2: Ensure cURL extension for PHP is installedOn Windows, people often use WAMP (Windows, Apache, MySQL, PHP) bundles for local development. Fortunately, cURL extension is pre-installed with those bundles, so you can proceed to Step 3.On Linux, it depends on which Linux distro the server is installed with, so you might need to run the appropriate command.For example, with Ubuntu/Debian server, you need to run this command:for php7:-sudo apt-get install php7.0-curlAfter that, restart the Apache server:sudo service apache2 restartfor php5:-sudo apt-get install php5-curlAfter that, restart the Apache server:sudo /etc/init.d/apache2 restartAfter the Apache server has restarted, the extension should be enabled by default. You might use the method at Step 1 to check, and if not, please proceed to the next step.Step 3: Enable cURL extension in “php.ini” fileLoad the “php.ini” file located in Step 1 into your favorite text editor (if you are using Windows, we suggest Notepad++), then search for “php_curl”. At this point, you need to uncomment the line by removing the semicolon at the beginning of the line, as below.After saving the file, restart the Apache server. Go to phpinfo page again to see if the extension is enabled.
If you see something like that, then congratulations, you have successfully enabled PHP cURL!
Monday, March 9, 2015
How can I use grep to find a word inside a folder?
grep -nr yourString* .
The dot at the end searches the current directory, and
-r searches sub-directories.grep -nr MobileAppSer* . (Will search for MobileAppServlet.java or .class or .txt; MobileAppASer*.* is another way to do the same thing.)Tuesday, March 3, 2015
How To Install the Firefox Developer Edition in Linux Ubuntu 14.10, Ubuntu 14.04 & Others
Method 1
- Install Firefox Developer Edition, formerly know as Aurora by running the following commands:
sudo add-apt-repository ppa:ubuntu-mozilla-daily/firefox-aurora
sudo apt-get update
sudo apt-get install firefox
Ubuntu versions supported: Utopic (14.10), Trusty (14.04), Precise (12.04).
Note that this method will replace your current Firefox installation.
Method 2
- Download the firefox developer edition here:
https://www.mozilla.org/en-US/firefox/developer/ - Extract the file manually to /opt/firefox/
- Open Nautilus: Go to Edit->Preferences-> Behavior-> click on “Run executable text files when they are opened”
- Go to the file ‘firefox’ in /opt/firefox/
- Right click and select Properties–> Permissions–> Execute: Allow executing file as a program.
- Open terminal and type:
- 'gnome-desktop-item-edit' not installed in your computer then you want to run following command
sudo apt-get install gnome-panel
then run following command
gnome-desktop-item-edit ~/.local/share/applications --create-newCreate a shortcut and it’s done.Tuesday, January 27, 2015
How to use open ssh key?
The OP already has a key, it is a .ppk which is a format used by Putty. The OP has converted it to an open ssh key already.
To use the key,
First, by default, the key should stored in ~/.ssh with permissions of 600 as outlined above.
Second, you have two options to use the key.
Option 1 - Use putty - You can install and use putty in Linux. Putty can use the key in either format.
Option 2 - Use ssh on the command line
ssh -i ~/.ssh/your_key user@server
If you have any errors , post them here.
How to establish ssh key pair when “Host key verification failed”
I have set up ssh key pairs between my desktop and two servers, and from the servers to my desktop, but after reinstalling the OS on my desktop, I can't re-establish the keypair going into my desktop by this:
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t
ssh-copy-id username@server
I get the following error:
(names in italics changed to protect the innocent My desktop is Ubuntu, and I can't find the answerhere)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is ab:cd:ef:gh Please contact your system administrator. Add correct host key in /home/user/.ssh/known_hosts to get rid of this message. Offending key in /home/user/.ssh/known_hosts:1 RSA host key for user.server has changed and you have requested strict checking. Host key verification failed.
Solution
ssh-keygen -R hostname
This deletes the offending key from the
known_hosts
The man page entry reads:
-R hostnameRemoves all keys belonging to hostname from a known_hosts file. This option is useful to delete hashed hosts (see the -H option above).
How to convert .ppk key to OpenSSH key under Linux (ubuntu)
Do it with Putty.
- Linux: with your package manager, install PuTTY (or the more minimal PuTTY-tools):
- Ubuntu
sudo apt-get install putty-tools
Place your keys in some directory, e.g. your home folder. Now convert the PPK keys to SSH keypairs:cache search
To generate the private key:
cd ~
puttygen id_dsa.ppk -O private-openssh -o id_dsa
and to generate the public key:
puttygen id_dsa.ppk -O public-openssh -o id_dsa.pub
Move these keys to
~/.ssh and make sure the permissions are set to private for your private key:mkdir -p ~/.ssh
mv -i ~/id_dsa* ~/.ssh
chmod 600 ~/.ssh/id_dsa
chmod 666 ~/.ssh/id_dsa.pub
If you have already tried to perform a 'git clone' operation you might need to do this also
chmod 666 ~/.ssh/known_hosts
Friday, October 28, 2011
how can i unzip rar. files
open terminal
then .rar files can extract normal way.
apt-get install unrar
then .rar files can extract normal way.
Tuesday, October 18, 2011
How to move mysql database to another drive or partition
First copy database to current mysql directory
(my source directory is /home/viranga/mysql1/ and destination is /var/lib/mysql/ )
Give permission to it.
(my source directory is /home/viranga/mysql1/ and destination is /var/lib/mysql/ )
sudo cp -r /home/viranga/mysql1/database /var/lib/mysql/database
Give permission to it.
sudo chown -R mysql:mysql /var/lib/mysql/database
Thursday, September 15, 2011
How to enable curl support with PHP (for ubuntu)
Run following command in terminal
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Monday, September 12, 2011
How to install Eclipse 3.7 on Ubuntu 11.04
The Eclipse packages in Ubuntu are are very out of date. The latest version in the Ubuntu repos is 3.5.2 where as the latest version of Eclipse is 3.7. I’m posting this because Ubuntu 11.04 uses the new Unity desktop which uses overlay-scrollbars (scrolls bars that are hidden until you hover over them). For some reason Eclipse 5.3.2 doesn’t like to play nice with the overlay scrollbars, and I’d rather use the newest version anyways. With Eclipse, you can just download the tar.gz file from eclipse.org and run it no problem, but I like set things up in a cleaner fashion, so here’s how I did it.
1) Download Eclipse. I got eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz
2) Extract it
3) Move to /opt/ folder
5) Create a gnome menu item
6) Launch Eclipse for the first time
1) Download Eclipse. I got eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz
2) Extract it
Or just be lazy and Right Click > Extract Heretar xzf eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz
3) Move to /opt/ folder
4) Create an eclipse executable in your pathmv eclipse /opt/ sudo chown -R root:root eclipse sudo chmod -R +r eclipse
copy this into nanosudo touch /usr/bin/eclipse sudo chmod 755 /usr/bin/eclipse sudo nano /usr/bin/eclipse
save the file (^O = Ctrl+o) and exit nano (^X = Ctrl+x)#!/bin/sh #export MOZILLA_FIVE_HOME="/usr/lib/mozilla/" export ECLIPSE_HOME="/opt/eclipse" $ECLIPSE_HOME/eclipse $*
5) Create a gnome menu item
copy this into nanosudo nano /usr/share/applications/eclipse.desktop
save and exit nano[Desktop Entry] Encoding=UTF-8 Name=Eclipse Comment=Eclipse IDE Exec=eclipse Icon=/opt/eclipse/icon.xpm Terminal=false Type=Application Categories=GNOME;Application;Development; StartupNotify=true
6) Launch Eclipse for the first time
/opt/eclipse/eclipse -clean &
Wednesday, September 7, 2011
Useful commands for ubuntu
For read apache error log
get apptitude
enable rewrite engine
tail -f /var/log/apache2/error.log
get apptitude
sudo apt-cache search aptitude
sudo apt-get install aptitude
sudo aptitude search rewrite
enable rewrite engine
sudo a2enmod rewrite
Tuesday, August 30, 2011
How to setup virtual host in ubuntu
Step 1: setup a virtual domain
open /etc/hosts and add a virtual domain with a specific local IP. In this file it contains ip and domain name separated by a space. You can also add the port using a colon with the IP. Lets assume that our virtual domain name is “domain.local” – and It will listen to the ip “127.0.0.1″
so we will add the following line to our /etc/hosts file
127.0.0.1 domain.local
now whenever you point to http://domain.local – your browser will actually open http://127.0.0.1
Step 2: configure virtual host with apache
here we will configure our newly added virtual domain against apache as a virtual host, and did I forget to say, with mod_rewrite enabled 
goto /etc/apache2/sites-available and create a file named “domain.local” – I recommend to keep it the same name as your virtual domain.
sudo gedit /etc/apache2/sites-available/domain.local
write the following contents inside. but please note to create the appropriate directory before linking your virtual host with that, for example we’ve create a folder named “/var/www/domain” and linked that directory as my document root in the following configuration file.
<VirtualHost *:80>
ServerName domain.local
DocumentRoot " /var/www/domain"
DirectoryIndex index.html index.php
<Directory " /var/www/domain">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
now create a symbolic link of this file to /etc/apache2/sites-enabled directory as “domain.local”
sudo ln -s /etc/apache2/sites-available/domain.local /etc/apache2/sites-enabled/domain.local
Step 3: restart apache (or reload)
simple, either one of the followings
simple, either one of the followings
sudo /etc/init.d/apache2 restart
or
sudo /etc/init.d/apache2 reload
and you are done! now you can point your browser to http://domain.local
Subscribe to:
Posts (Atom)


