Symlinks are used a lot in Linux- and Unix-based systems so you may be wondering as to what exactly a “symlink” is. If you have Linux VPS Hosting and you use SSH, you’ll often find many files in the file structure are symlinks.
What are symlinks used for?Symlinks are a specific type of file that has a reference to a physical location on the Linux server hard drive – such as another file or directory that exists on the machine’s hard drive. The most common symlink you’ll likely come across when using an FTP client is the www and public_html directories. The www directory is a symlink to the public_html physical directory. So this means any files or directories uploaded to the www folder is the same as doing so directly in the public_html folder. The two that seemingly look like two separate folders are merely just one.
Symlinks are very useful. For example, if you use a Linux-based operating system on your desktop, you could easily create a symbolic link to the Applications folder on your desktop. So in this way, a symlink would act as a shortcut to that specific folder, that resides in a specific location on the hard drive. However, in the case of a Linux web server, you may have an important shell script in one folder but there are two folders on the server that do similar functions, so for human convenience you may want to create a symlink to the shell script on the other similar folder. No extra storage space is really being used; you could simply have multiple copies of the shell script on the hard drive, but that wastes unnecessary space, which is another reason why symlinks are useful.
In fact, symlinks can save a lot of space, because a symlink simply contains a text string that determines where the operating system needs to go to find the physical file or directory on the server.
Uses Of SSH Client Commands In Your Linux Server :
SSH allows you to connect to a remote computer – for example, your Web server. This protocol allows commands to be carried out on that computer, such as moving and copying files, creating directories (folders), and running scripts. A SSH client should be installed on your computer to be able to talk to the remote server.
ls
command
LS is stands for “list”. Ls helps user to lists all the files and directories in their current directory. User have to type ls and press Enter to find out a listing appear in the terminal window:
username@webserver:~$ ls myfile.txt myfile2.txt mysite.com
cd
command
Cd stands for “change directory”. User can able to to move into and out of directories, much like double-clicking folders on his/her PC with cd command. Such as, if ownsite.com listed above is the directory containing user’s website, he/she can move into the directory as follows:
username@webserver:~$ cd ownsite.com
User can then do another ls to list the contents of the ownsite.com directory:
username@webserver:~/mysite.com$ ls cgi-bin htdocs logs
To move back up a directory, use cd .. (“..” means “the parent directory”). After use this, user can be back in original directory:
username@webserver:~/mysite.com$ cd .. username@webserver:~$ ls myfile.txt myfile2.txt mysite.com
C. The pwd command
Its important to know your exact current directory. To find this out, type the command pwd (short for “print working directory”) and press Enter. The computer displays the full path to the current directory.
username@webserver:~$ pwd /home/users/username/
D. The more command
To quickly browse through the contents of a text file on your server. Just type more followed by the name of your file, and press Enter:
username@webserver:~$ more myfile.txt Project Gutenberg's The Complete Works of Artemus Ward, Part 1 #1 of this seven part series by Charles Farrar Browne Copyright laws are changing all over the world, be sure to check the laws for your country before redistributing these files!!! Please take a look at the important information in this header. We encourage you to keep this file on your own disk, keeping an electronic path open for the next readers. Please do not remove this. This should be the first thing seen when anyone opens the book. Do not change or edit it without written permission. The words are carefully chosen to provide users with the information they --More--(16%)
Uses Of Grep Command In Unix And Linux Server
The name, “grep” is indicative of the operation which this command performs. It is executed using the Unix/Linux text editor ed: g/re/p
grep'word' filename grep'string1 string2' filename cat otherfile | grep'something' command | grep'something' command option1 | grep'data' grep --color 'data' fileName
Search /etc/passwd for boo user:
$ grep boo /etc/passwd
User can force grep to ignore word case. Such as, match boo, Boo, BOO and another combination with -i option:
$ grep -i "boo" /etc/passwd
User can search recursively. Such as, read all files under each directory for a string “192.168.2.6″
$ grep -r "192.168.2.6" /etc/
When the user searches for boo, grep will match fooboo, boo123, etc. Grep can be made to select only the lines which contain matching whole words such as only the word boo.
$ grep -w "boo" /path/to/file
use egrep as follows:
$ egrep -w 'word1|word2' /path/to/file
*Way To Count Lines Content Similar Words With grep Command:
User can get the number of times which the pattern has been matched for every file with -c (count) option:
$ grep -c 'word' /path/to/file
Also keep in mind that the user can utilize -n option, which causes grep to precede every line of output with the number of the line in the text file from which it was obtained:
$ grep -n 'word' /path/to/file
The -v option is used to print inverts of the the match; meaning that it will return only those lines that do not contain the given word. For example print all line that do not contain the word bar
$ grep -v bar /path/to/file
grep command is also used with pipes. Like as follows :
# dmesg | egrep '(s|h)d[a-z]'
Display cpu model name:
# cat /proc/cpuinfo | grep -i 'Model'
User can use the above command without shell pipe, like below :
# grep -i 'Model' /proc/cpuinfo
Use the -l option to list file name whose contents mention main():
$ grep -l 'main' *.c
Users can also force grep to display output in colors:
$ grep --color vivek /etc/passwd
Use Coupon Code – summerdedicated – and Avail 5% Recurring Discount on Dedicated Server
When managing several servers with different operating systems and versions, you might not be able to identify the LAMP version being used, it could happen with the client too. Here is a small method to check the LAMP version.
1) Linux Version:-
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.1 (Santiago)
[root@localhost ~]# uname -a
Linux node1.oriensoft.com 2.6.32-042stab032.1 #1 SMP Sat Aug 13 18:16:00 MSD 2011 x86_64 x86_64 x86_64 GNU/Linux
As per above out put Operating System is RHEL 6.1 (64-Bit).
2) Apache Version:-
[root@loalhost ~]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Aug 14 2010 08:53:20
As per above out put Apache version is 2.2.15.
3) Mysql Version:-
[root@localhost ~]# mysql -V
mysql Ver 14.14 Distrib 5.1.47, for redhat-linux-gnu (x86_64) using readline 5.1
As per above out put Mysql Version is 5.1.47 (64-Bit).
4) PHP Version:-
[root@localhost ~]# php -v
PHP 5.3.2 (cli) (built: Aug 17 2010 04:35:29)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
As per above out put PHP Version is 5.3.2.
Uses of Tar Command in Unix and Linux Server :
For archiving purposes on the Unix platform, tar command is command to be used. Knowing the various tar command options will help you to be a master of the archive file manipulation.
It is the most basic command to create a tar archive.
$ tar cvf archive_name.tar dirname/
Note :
c – create a new archive
v – verbosely list files which are processed.
f – following is the archive file name
The above used tar cvf, can’t offer any compression. So, if you want to utilize a gzip compression on the tar archive then you can utilize the z option as follows.
$ tar cvzf archive_name.tar.gz dirname/
Note :
z – filter the archive through gzip
Note:
.tgz is similar as .tar.gz
Create a bzip2 tar archive as shown below:
$ tar cvfj archive_name.tar.bz2 dirname/
Note :
j – filter the archive through bzip2
Note:
.tbz and .tb2 is similar as .tar.bz2
B. Extracting (untar) an archive with tar command
Extract a tar file with option x as shown below:
$ tar xvf archive_name.tar
Note :
x – extract files from archive
Use the option z for uncompressing a gzip tar archive.
$ tar xvfz archive_name.tar.gz
Use the option j for uncompressing a bzip2 tar archive.
$ tar xvfj archive_name.tar.bz2
You can find out the *.tar file content before extracting as shown below.
$ tar tvf archive_name.tar
You can find out the *.tar.gz file content before extracting as shown below.
$ tar tvfz archive_name.tar.gz
You can find out the *.tar.bz2 file content before extracting as shown below.
$ tar tvfj archive_name.tar.bz2
You can add additional files to an existing tar archive as shown below. Like, to append a file to *.tar file do the following:
$ tar rvf archive_name.tar updatedfile
This updatedfile will be added to the existing archive_name.tar. Adding a directory to the tar is also similar,
$ tar rvf archive_name.tar newdir/
Note:
You can’t add file or directory to a compressed archive. In that case you will get the following error
$ tar rvfz archive_name.tgz newfile
tar: Cannot update compressed archives
Try `tar --help' or `tar --usage' for more information.
Before creating the tar file you can estimate the tar file size ( in KB ) with the command below:
$ tar -cf - /directory/to/archive/ | wc -c
20480
Before creating the tar.gz, tar.bz2 files, you can estimates the compressed tar file size ( in KB ) with the commands below:
$ tar -czf – /directory/to/archive/ | wc -c 508 $ tar -cjf – /directory/to/archive/ | wc -c 428