`

Ubuntu Beginer

阅读更多

 

Ubuntu version

========================================================

uname -a

uname -r

 

Ubuntu rpm / VMware / root / java / vi / putty / jboss

========================================================

putty

-------------------

1. install ssh server in Linux;

    $sudo apt-get install ssh

2. use NAT network connection;

 

rpm

--------------------

rpm -ivh package.ix86.rpm

rpm -ql packagename

rpm -e packagename

rpm -Uvh package.ix86.rpm

 

install VMware-tools

--------------------

cp -a /media/cdrom/VMwareTools* /tmp/

cd /tmp/

tar -vxzf VMwareTools*.gz

cd vmware-tools-distrib/

sudo ./vmware-install.pl

 

mount a ext disk

--------------------

1. shutdown the running Linux;

2. right-click on the Linux OS -> Virtual Machine Settings;

3. In "Hardware" tab, click "Add" -> Add a hard disk -> Create a new virtual disk -> SCSI(recommended) -> set the size -> OK;

4. as a result, a new disk named - Hard Disk 2 will display in Linux OS settings.

 

login as root:

# fdisk -l ## list all partitions information

# fdisk /dev/sdb ## begin to make partition of new disk

m ## usage

p ## print the current disk partition table

n ## create a new partition

p ## select primary partition

1 ## the partition No.

p ## print the up to date partition information table

w ## write the new partition to disk

# mkfs.ext3 /dev/sdb1 ## format the new partition using ext3

# fdisk -l ## list information

# mkdir /data1   ## make new directory for mount - /data1

# mount /dev/sdb1 /data1 ## mount sdb1 on /data1

# df -h   ## reboot system to check the disk information

Move data:

du -hs /usr ##check the folder size

1. move all data in /usr to /data1 (we can use $sudo mv /usr/* /data1/)

2. clear /usr directory:

# rm -r /usr

3. create /usr directory again:

# mkdir /usr

4. umount /dev/sdb1 from /data1, and mount it on /usr:

# umount /dev/sdb1 /data1

# mount /dev/sdb1 /usr

4、# vi /etc/fstab ## modify /etc/fstab, let system mount the new disk on boost automatically.

add below line in the end(separate by Tab):

        /dev/sdb1                /usr                     ext3     defaults         1 2

4. OK, reboot system, check the disk information. you will find the extension disk has been mounted to system.

# df -h

              File System           Volumn   Used Avaliable Used% Mount point

              /dev/sda2              3.6G    1.3G   2.4G     35%  /

              udev                   125M    124K   125M     1%   /dev

              /dev/sdb1              4.0G    2.3G   1.6G     60%  /usr

 

Create root user in Ubuntu:

--------------------

$ sudo sh

Asran's Password: ******

#

(now you are in root session)

#whoami

root

 

If you want to be able to login as root, you need to define a password for root:

$ sudo passwd

Asran's Password:

Enter new UNIX password: *****

Retype new UNIX password: *****

change current user pwd:

#passwd

$sudo password username ## root can change any use's password without regex restrictions.

vi

-------------------

upgrade to vim

$ sudo apt-get install vim

 

java

-------------------

$sh jdk-6u16-linux-i586.bin

vim .profile

set JAVA_HOME and CLASSPATH in personnal environment

JAVA_HOME="/home/asran/java/jdk1.6.0_16"

export JAVA_HOME

PATH="$JAVA_HOME/bin:$PATH"

export PATH

CLASSPATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib"

export CLASSPATH

 

jboss

-------------------

./run.sh -b 192.168.175.128 -&

./shutdown -S

wget http://192.168.175.128:8080

 

 

Install .deb .bin

========================================================

*.deb: $sudo dpkg -i *.deb

*.bin: $sh *.bin

 

Install Mysql / SVN

========================================================

svn

----------------------------

1. Install svn client:

$sudo apt-get install subversion

2. checkout:

[workspace]$svn checkout http://opensvn.csie.org/asran --username asran.deng

prompt for password:******

3. update:

[workspace]$svn update

4. add new file:

[workdirectory]$svn add hello.c

5. remove:

[workdirectory]$svn delete hello.cgi

5. commit(if there are new files, then need add them first):

[workdirectory]$svn commit

6. create a new project:

$svn mkdir --parents -m "" http://opensvn.csie.org/asran/c++

then checkout that project.

 

mysql

---------------------------

1. $sudo apt-get install mysql-server

2. $sudo aptitude install libmysqlclient15-dev  ## install develop libraries for developer

compile: cc -o mysql.cgi mysql.c -lmysqlclient

 

 

chmod [-cfvR] [--help] [--version] mode file

========================================================

mode : permission configuration,format : [ugoa...][[+-=][rwxX]...][,...]

u - the file owner

g - the same group of file owner

o - others

a - all of three

+ grant - revoke = only set (privileges)

r readable, w writable, x executable, X unknow yet?

-c : if the file privilege really be changed, then display the modification action

-f : if the file privilege can't be changed, then also display nothing

-v : show verbose

-R : subdirectory recursively

--help : help information

--version : display version

e.g.

$chmod ugo+r file1.txt (everyone can read it)

equivalent with: $chmod a+r file1.txt

$chmod ug+w,o-w file1.txt file2.txt (owner and owner group can write file1.txt and file2.txt, others can't write)

$chmod u+x ex1.py (owner can execute ex1.py)

$chmod -R a+r * (everyone can read the files in current directory and its subdirectories)

$chmod 777 file

syntax: chmod abc file

a - user

b - group

c - other

r=4 w=2 x=1

rwx: 4+2+1=7

rw-: 4+2=6

r-x: 4+1=7

e.g.

chmod a=rwx file = chmod 777 file

chmod ug=rwx,o=x file = chmod 771 file

chmod 4755 filename ## as root privilege

sudo chmod 600 ***

sudo chmod 644 ***

sudo chmod 700 ***

sudo chmod 666 ***

sudo chmod 777 ***

 

 

search

========================================================

locate is great for searching the entire file system

$locate xorg.conf

$locate -r '/xorg.conf$' (regular expression)

$locate -i 'monthly report' (insensitive)

$locate -b Desktop (hide sub-directories & files)

$sudo updatedb (update index)

 

which finds where a command lives

$which mysql

$which svn

 

find the source, man page, and other associated directories

$whereis firefox

 

$find everything

$find / -name game

$find /home -user joe

$find /usr -name *stat

$find /var/spool -mtime +60

$find . -type f -perm -u=x, -o=r -exec rm -i {} \;

$find / -name foo 2>/dev/null  ## redirect the error message.

$find -print0 ## separate file pathname with NUL.

$find . -name foo\*bar ## This will search from the current directory down for foo*bar (that is, any filename that begins with foo and ends with bar).

$find / -type f -mtime -7 | xargs tar -rf weekly_incremental.tar

$gzip weekly_incremental.tar

## will find any regular files (i.e., not directories or other special files) with the criteria "-type f", and only those modified seven or fewer days ago ("-mtime -7")

## Using the tar option "-c" is dangerous here;  xargs may invoke tar several times if there are many files found and each "-c" will cause tar to over-write the previous invocation.  The "-r" option appends files to an archive.  Other options such as those that would permit filenames containing spaces would be useful in a "production quality" backup script.

$find / -name core | xargs /bin/rm -f

$find / -name core -exec /bin/rm -f '{}' \; # same thing

$find / -name core -delete                  # same if using Gnu find

$find / -mmin -10 ## locate files modified less than 10 minutes ago.

$ls -l | wc -l ## count the files

$find / -name core | wc -l

 

$grep '_IO_FILE' /usr/include/*.h ## full-text search

 

 

Compression / Extraction

========================================================

zip

# zip -r archive_name.zip directory_to_compress

# unzip archive_name.zip

gz

gzip filename.ext

gunzip filename.gz

tar

# tar -cvf archive_name.tar directory_to_compress

# tar -xvf archive_name.tar

# tar -xvf archive_name.tar -C /tmp/extract_here/

tar.gz

# tar -zcvf archive_name.tar.gz directory_to_compress

# tar -zxvf archive_name.tar.gz

# tar -zxvf archive_name.tar.gz -C /tmp/extract_here/

# tar -xzvf foo.tgz

tar.bz2

# tar -jcvf archive_name.tar.bz2 directory_to_compress

# tar -jxvf archive_name.tar.bz2 -C /tmp/extract_here/

$*** -tf zipfilename ## list content of compress file

 

 

vim

========================================================

:set showmode

hjkl -------move cursor

x  ---------- remove character

dd ---------- delete whole line

Y/yy ---------- copy one line

nY ------------ copy n line

yG ------------ copy to the end of file

yw ------------ copy to the end of word(inline)

y$ ------------ copy to the end of line (inline)

P ------------- paste above/before

p ------------- paste below/after

 

J  ---------- join two lines

u  ---------- undo

Ctrl-R ---------- redo

U ------------undo whole line

a -------------append

o -------------insert new line under current row

O -------------insert new line above current row

3x ------------cut 3 characters from cursor

ZZ -------------write and exit

:q! ------------exit without saving

:e! ------------reload file content

:help

 

:set number

:set nonumber

:set ts=2 --------- display tab as 2 size(or add [:set ts=2] in ~/.vimrc, if not existing, just create one)

:syntax on/off ------ highlight key words

 

gg ------------- go header

G -------------- go bottom

nG ------------- go n-th line below

9k ------------ go 9 lines above

H -------------- header

M --------------- middle

L --------------Last

Ctrl-G ----------tell where am i

Ctrl-U ---------- move up

Ctrl-D ---------- move down

Ctrl-E

Ctrl-Y

Ctrl-F

Ctrl-B

zz -------------- bring the current row to the middle of screen

zt -------------- to top

zb -------------- to bottom

/search

?search

n ------------next

N ------------opposite direction search

 

 

Apache Web Server (cgi / perl / php)

========================================================

apache2

--------------------

$sudo aptitude install apache2 ### install Apache HTTP Server

$sudo vim /etc/apache2/apache2.conf

Add:

ServerName localhost / ServerName yourserverip /

$sudo apache2ctl restart

 

cgi:

$mkdir /home/asran/www/cgi-bin

$sudo vim /etc/apache2/sites-avaliable/default

comment out the original cgi settings

add_

    ScriptAlias /cgi-bin/ /home/asran/www/cgi-bin/

    <Directory "/home/asran/www/cgi-bin">

        Options ExecCGI

        AddHandler cgi-script cgi pl

    </Directory>

 

$cc -o test.cgi test.c

$cp test.cgi /home/asran/www/cgi-bin/

open browser: http://serverip/cgi-bin/test.cgi

 

php:

$mkdir /home/asran/www

$sudo vim /etc/apache2/conf.d

change /var/www -> /home/asran/www/

 

$sudo apache2ctl restart

 

if prompt to download php file, then

$sudo apt-get install libapache2-mod-php5

$sudo apache2ctl restart

 

 

 

package management (dpkg / apt-get / aptitude)

========================================================

package management

---------------------------

dpkg:

$sudo dpkg -l |grep apache2  ## list all installed package

$sudo dpkg -L packagename ## list the files which installed by specified package

$sudo dpkg -i *.deb        ## install a local package

$sudo dpkg -r packagename ## uninstall the specified package(not recommand)

$sudo dpkg -S filename  ## find the current file belongs to which package

 

apt-get:

$sudo apt-get install packagename1 packagename2 packagename3

$sudo apt-get remove --purge packagename1 packagename2 packagename3

$sudo apt-get update ## update the local repository index

$sudo apt-get upgrade packagename  ## upgrade package

$sudo apt-get dist-upgrade ## upgrade Ubuntu Server Edition system

$sudo do-release-upgrade ## upgrade OS

$sudo do-release-upgrade -d ## upgrade OS to a development version

 

 

Runlevel

========================================================

$sudo runlevel

$telinit n

change Ubuntu to run in text-mode by default:

create new file:

$sudo vim /etc/inittab

    id:3:initdefault:

remove the gdm service from /etc/tc3.d/ directory:

$ls /etc/rc3.d/

lrwxrwxrwx 1 root root  13 2009-09-06 14:50 S30gdm -> ../init.d/gdm

## $sudo ln -s ../init.d/gdm S30gdm

$sudo reboot

 

 

FTP

========================================================

$ftp

ftp>open asran99.zymichost.com

ftp>ls

ftp>cd

ftp>get file.txt

ftp>put file2.txt

ftp>delete file3.txt

ftp>bye

 

User/Group

========================================================

$w

$who

$whoami

$passwd [username]

 

Install goole pinyin

========================================================

$sudo aptitude install git-core

$git clone git://github.com/tchaikov/scim-googlepinyin.git

$cd scim-googlepinyin.git

 

$aptitude install autotools-dev libgtk2.0-dev libscim-dev libtool automake

$./autogen.sh

$make

$sudo make install

 

launch scim:

scim -f socket -c socket -d

 

IBus has been started! If you can not use IBus, please add below lines in $HOME/.bashrc, and relogin your desktop.

  export GTK_IM_MODULE=ibus

  export XMODIFIERS=@im=ibus

  export QT_IM_MODULE=ibus

 

Install LDAP in Ubuntu9.10

========================================================

tar zxvf db-5.1.19.tar.tar

cd build_unix/

../dist/configure

sudo make

sudo make install

vim /home/asran/.profile

sudo apt-get install libdb-dev

 

gunzip -c openldap-2.4.23.tgz | tar xvfB -

sudo ./configure

sudo make depend

sudo make

sudo make test

sudo make install

 

sudo vim /usr/local/etc/openldap/slapd.conf

 

sudo /usr/local/libexec/slapd

 

分享到:
评论

相关推荐

    ubuntu 初级 入门 beginner

    借用书中的话 本书的适用范围 1. 从未接触过 Linux 的人群; 2. 初次接触 Linux 的人群; 3. 已经适应了 Windows 操作习惯但又想尝试 Linux 的人群; 4. 认为 Linux 难用而放弃了 Linux 或正准备放弃 Linux 的...

    OpenStack Beginner’s Guide for Ubuntu Natty.pdf

    Ubuntu Natty是Ubuntu操作系统的一个版本,代号为“Natty Narwhal”,发布于2011年4月28日。在本指南中,OpenStack是为这个版本的Ubuntu操作系统定制的。 6. **文档版本和版权信息** 文档版本为v1.0,发布日期为...

    Linux The Complete Beginner's Guide (2016)

    《Linux The Complete Beginner's Guide (2016)》是一本针对初学者的Linux入门书籍,由Arthur Fyrus Aqil撰写,并于2016年出版。这本书的目标读者是那些对Linux操作系统完全没有经验的用户,内容覆盖了Linux的基础...

    Nginx From Beginner to Pro(Apress,2016)

    Nginx: From Beginner to Pro teaches the Nginx server in a practical way. Frequently, it is found that web administrators struggle to fix the skill set gaps that happen due to a platform change. ...

    Ubuntu Pocket Guide and Reference: A concise companion for day-to-day Ubuntu use

    ### Ubuntu Pocket Guide... Whether you're a complete beginner or an experienced user looking to enhance your knowledge, this guide offers practical advice and tips to help you get the most out of Ubuntu.

    基于Ubuntu的私有云平台搭建手册

    ### 基于Ubuntu的私有云平台搭建:Eucalyptus Beginner's Guide #### 知识点一:Eucalyptus与Ubuntu私有云构建 **Eucalyptus**(Elastic Utility Computing Architecture for Linking Your Programs To Useful ...

    Sams.Ubuntu.Unleashed.2010.Edition.Dec.2009.pdf

    Whether you're a beginner just starting out or an experienced user seeking advanced customization options, this book provides all the necessary information to make the most of Ubuntu. Its ...

    docker 服务(ubuntu16.04环境)

    虚拟机下UBUNTU环境DOCKER服务(ASP.NET CORE WEB APPLICAITON-&gt;webapi接口服务)

    beginner_tutorials

    Ubuntu 18.04 通过命令行进行标准安装 cd ~/catkin_ws/src git clone --recursive https://github.com/adigoswami/beginner_tutorials cd .. catkin_make 打开以下终端,并在其中运行以下命令: 1号航站楼: ...

    Linux Administration A Beginner's Guide

    Linux系统包括众多发行版,如Red Hat、Ubuntu、Debian等,每个发行版都有其特定的管理和操作方式。 本书的前言部分说明了版权信息和使用条款,即本书是受版权法保护的,未经出版商同意,不得非法复制、分发、存储或...

    GeoServer Beginner's Guide Brian.pdf

    - **检查Ubuntu系统中的Java环境**:使用命令行工具检查Java是否安装。 - **安装Java运行环境(JRE)**: - 在Windows系统中安装JRE。 - 在Ubuntu系统中安装JRE。 - **安装Apache Tomcat**: - **在Windows上...

    Linux Administration A Beginner_s Guide-Fifth Edition

    《Linux Administration A Beginner's Guide - Fifth Edition》是针对初学者的Linux系统管理指南,第五版。这本书深入浅出地介绍了Linux操作系统的基础知识和系统管理技巧,对于想要踏入Linux世界的人来说是一份宝贵...

    nginx from beginner to pro

    - 安装Nginx:在不同操作系统(如Ubuntu、CentOS)上安装Nginx的步骤。 - 配置文件结构:理解`nginx.conf`主配置文件及其包含的各部分,如http、server、location块。 - 基本配置指令:如listen、root、index、...

    ubuntu设置自启动python程序-自启动文件格式

    ubuntu设置自启动python程序-自启动文件格式

    ubuntu设置自启动python程序-自启动文件使用说明

    ubuntu设置自启动python程序-自启动文件格式

Global site tag (gtag.js) - Google Analytics