Вы находитесь на странице: 1из 6

To copy file/folder

sudo cp -R /source /destination

Commands

sudo: Executing Commands with Elevated Privileges

• Most of the following commands will need to be prefaced with the sudo command. This
elevates privileges to the root-user administrative level temporarily, which is necessary
when working with directories or files not owned by your user account. When using sudo
you will be prompted for your password. Only users with sudo (administrative) privileges
will be able to use this command. (Please see RootSudo for more information on using
sudo.)

File & Directory Commands

• The tilde (~) symbol stands for your home directory. If you are user, then the tilde (~)
stands for /home/user

• pwd: The pwd command will allow you to know in which directory you're located (pwd
stands for "print working directory"). Example: "pwd" in the Desktop directory will show
"~/Desktop". Note that the Gnome Terminal also displays this information in the title bar of
its window. A useful gnemonic is "present working directory."

• ls: The ls command will show you ('list') the files in your current directory. Used with
certain options, you can see sizes of files, when files were made, and permissions of files.
Example: "ls ~" will show you the files that are in your home directory.

• cd: The cd command will allow you to change directories. When you open a terminal you
will be in your home directory. To move around the file system you will use cd. Examples:
• To navigate into the root directory, use "cd /"

• To navigate to your home directory, use "cd" or "cd ~"

• To navigate up one directory level, use "cd .."

• To navigate to the previous directory (or back), use "cd -"

• To navigate through multiple levels of directory at once, specify the full directory
path that you want to go to. For example, use, "cd /var/www" to go directly to
the /www subdirectory of /var/. As another example, "cd ~/Desktop" will move you
to the Desktop subdirectory inside your home directory.

• cp: The cp command will make a copy of a file for you. Example: "cp file foo" will make
a exact copy of "file" and name it "foo", but the file "file" will still be there. If you are
copying a directory, you must use "cp -r directory foo" (copy recursively). (To understand
what "recursively" means, think of it this way: to copy the directory and all its files and
subdirectories and all their files and subdirectories of the subdirectories and all their files,
and on and on, "recursively")

• mv: The mv command will move a file to a different location or will rename a file.
Examples are as follows: "mv file foo" will rename the file "file" to "foo". "mv foo
~/Desktop" will move the file "foo" to your Desktop directory but will not rename it. You
must specify a new file name to rename a file.

• To save on typing, you can substitute '~' in place of the home directory.
• Note that if you are using mv with sudo you can use the ~ shortcut, because the
terminal expands the ~ to your home directory. However, when you open a root
shell with sudo -i or sudo -s, ~ will refer to the root account's home directory, not
your own.

• rm: Use this command to remove or delete a file in your directory.

• rmdir: The rmdir command will delete an empty directory. To delete a directory and all of
its contents recursively, use rm -r or -rf instead.

• mkdir: The mkdir command will allow you to create directories. Example: "mkdir music"
will create a directory called "music".
• man: The man command is used to show you the manual of other commands. Try "man
man" to get the man page for man itself. See the "Man & Getting Help" section down the
page for more information.

How to change read/write permissions


use :
sudo chmod -R 777 /folder_path

How to untar .tar. .tar.bz2, .tar.gz file


Type at the command prompt
tar xvzf file-1.0.tar.gz - for a gzip compress tar file (.tgz or .tar.gz)

tar xvjf file-1.0.tar.bz2 - for a bzip2 compressed tar file (.tbz or .tar.bz2)

tar xvf file-1.0.tar - for uncompressed tar file (.tar)

• x = eXtract, this indicated an extraction ( c = create to create )


• v = verbose (optional) the files with relative locations will be displayed.
• z = gzip-ped; j = bzip2-zipped
• f = from/to file ... (what is next after the f is the archive file)

The files will be extracted in the current folder (most of the times in a folder with the
name 'file-1.0').

How to install bin file


http://www.ehow.com/print/how_4578189_install-bin-file-ubuntu-linux.html
http://java.sun.com/javase/6/webnotes/install/jdk/install-linux-64-self-extracting.html

How to install sun-jdk


Download the latest JDK from Sun
For Ubuntu, choose the self extracting non rpm file, eg. jdk-6u4-linux-i586.bin
For Red Hat, SUSE, RPM package will work.

Insall fakeroot and java-package from terminal:


sudo apt-get install fakeroot
sudo apt-get install make-jpkg

Now, we create the .deb jdk package from terminal


sudo fakeroot make-jpkg jdk-6u20-linux-x64.bin

sudo dpkg -i sun-j2sdk1.6u20+update20_x64.deb


sudo update-alternatives --config java

Now, we ned to add Java to PATH and create JAVA_HOME


Type in terminal:
To declare session-wide variable per user
gedit ~/.bashrc

For system-wide variable use sudo gedit /etc/environment

In bashrc at the end after fi


JAVA_HOME="/usr/lib/j2sdk1.6-sun"
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Restart the server and check in terminal:


echo $JAVA_HOME
echo $PATH
java -version

How to install eclipse


Download eclipse and copy to /opt.
If java sdk is installed, you should be ready to use eclipse workspace.
How to install Tomcat
Download tomcat core binary distribution.

Untar download and copy to /opt


sudo tar zxfp apache-tomcat-5.5.15.tar.gz -C /opt
cd /opt
sudo ln -s apache-tomcat-5.5.15 tomcat

Edit tomcat users


sudoedit /opt/tomcat/conf/tomcat-users.xml

And add an admin and your own?


<user name="admin" password="admin" roles="manager,admin" />
<user name="yourname" password="blah" roles="manager,admin" />

To Auto-start Tomcat

Create a shell script named. 'tomcat' in directory /etc/init.d

Code:
#!/bin/bash
#
# Startup script for the Tomcat server
#
# chkconfig: - 83 53
# description: Starts and stops the Tomcat daemon.
# processname: tomcat
# pidfile: /var/run/tomcat.pid

# See how we were called.


case $1 in
start)
export JAVA_HOME=/usr/lib/j2sdk1.6-sun/
# export CLASSPATH=/usr/local/tomcat/common/lib/servlet-api.jar
# export CLASSPATH=/usr/local/tomcat/common/lib/jsp-api.jar
sh /opt/tomcat/bin/startup.sh
;;

stop)
sh /opt/tomcat/bin/shutdown.sh
;;
restart)
sh /opt/tomcat/bin/shutdown.sh
sh /opt/tomcat/bin/startup.sh
;;
*)
echo "Usage: /etc/init.d/tomcat start|stop|restart"
;;
esac

exit 0
3. I executed this lines:
Code:
chmod +x /etc/init.d/tomcat
ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat
and now my tomcat is there when I start up my linux

How to install mysql

sudo apt-get install mysql-server


sudo apt-get install mysql-client

Was unable to login so used:


sudo -i
/usr/bin/mysql_setpermission

created a root user and password in database mysql

Now check login by typing:


mysql -u root -p
Enter password: analatom

APACHE

Tip

Вам также может понравиться