Friday, June 25, 2010
Windows Internet Share through WIFI ad hoc
Monday, June 21, 2010
Linux File Commond
- Display the absolutly path of the current directory
pwd - Display the contained files and sub directories in the current directory
ls [option] [filenamePattern]
Most used options include -a for displaying all files, -l for displaying all the informations for each file, - Create one/more files
touch file name or file name pattern
eg: touch {report,draft}_{AUG,SEP,NOV}{1,2,3} - Create directory
mkdir - Remove directory
rmdir - Copy files
cp - Move files
mv - Link files
ln -s originalFile linkFile
ln originalFile linkFile - Display information, display all the matches of the wildcard pattern, that usefull to avoid operation on wrong files when use echo before use wildcard pattern delete or move files.
echo [wildcard pattern] - Change the file permissions
chmod permission fileName
Owner Group Others
execute write read execute write read execute write read
1 2 4 1 2 4 1 2 4 - Change the file owner
chown username filename - Change the file owner group
chown username:groupName fileName - Search files
- wildcard * ? ~
- Display file content
- cat filename display the contents of the file
- less fileName1 [fileName 2 …fileName n] view one or more files at the same time :n(to view next page) :p(to view previous page) to navigate from pages and automaticaly paginates the file.
- head -number fileName view the fist number of lines in the file
- tail -number fileName view the last number of lines in the file
Linux User Mangement Command
- Display current user information
- w display who is logged on and what they are doing.
- whoami display the current user’s username
- groups display the current user’s group
- id display the uid,gid and groups of the current user
- Create a user
useradd username - Switch between users
su username Note: su - change user to root user and current directory to root’s home directory. su root change user to root user without changing current directory.
Search files in Linux
There are couples of tools used to find things in Linux.
- find [where] [search patterns][actions]
search patterns include:
- -name fileNamePattern match is case sensitive
- -iname fileNamePattern match is case insensitive
- -size [+,-]size (b,c,w,k,M,G) + means great than -means less than
- -user username username is the owner of the files
- -mmin n searching files which be modified n mins ago
- -amin n searching files which be accessed n mins ago
- -and/-or/! are the boolean operator which connect two or more patterns
- -delete
- exec command
- $ find / -name ‘*.c’ 2>/dev/null
find any .c files under the root directory and discard the error message. 2 indicates the error stream in Linux, and /dev/null is the device where anything you send simply disappears. So 2>/dev/null in this case means that while finding for the files, in case any error messages pop up simply send them to /dev/null i.e. simply discard all error messages. - $ find /etc -name ‘*.conf’ -exec ls -l {} \;
find any .conf files under /etc directory and execute ls -l on the search result. {} indicate the search result \ indicate the end of the command.
Linux LVM Snapshot
LVM Snapshot use smaller logic volume to represent the whole data on the large logic volume and only save the data writing to the original LV when the snapshot LV is mounted. The snapshot LV will be automatically unmount when it is full. Thus the size of the snapshot LV must be larger than the possible data may changed during the time of the snapshot LV mount on the system.It is usfull when execute some script on the live system. For exmple back a database drive when the database still running.
To create a snapshot LV use following command:
# lvcreate -L10G -s -n snapshotName /dev/volgroupName/LVname
To mount a snapshot LV use following command:
# mkdir /mnt/locationName/snapshotLVName
# mount /dev/volgroupName/snapshotLVName /mnt/locationName/snapshotLVName
To create a snapshot LV use following command:
# lvcreate -L10G -s -n snapshotName /dev/volgroupName/LVname
To mount a snapshot LV use following command:
# mkdir /mnt/locationName/snapshotLVName
# mount /dev/volgroupName/snapshotLVName /mnt/locationName/snapshotLVName
To backup a LV tar -pczf /backups/root.tar.gz /mnt/locationName/snapshotLVName To remove a snapshot LV use following command: # umount /mnt/locationName/LVName # lvremove /dev/ops/dbbackup
Backup with tar
tar [operation] [option] target source
There are three commonly used operations `—create’, `—list’, and `—extract’ or ‘-c’, ‘-t’ and ‘-x’
And there are six commonly used options ‘-C’, ‘-f’, ‘-j’, ‘-p’, ‘-v’ and ‘-z’.
There are three commonly used operations `—create’, `—list’, and `—extract’ or ‘-c’, ‘-t’ and ‘-x’
And there are six commonly used options ‘-C’, ‘-f’, ‘-j’, ‘-p’, ‘-v’ and ‘-z’.
- ‘-C’, change to directory
- ‘-f’, use archive file or device F (default “-“, meaning stdin/stdout)
- ‘-j’, filter archive through bzip2, use to decompress *.bz2 files
- ‘-p’, extract all protection information
- ‘-v’, verbosely list files processed
- ‘-z’, filter the archive through gzip
- Verbosely create a tar archive name.tar from sourceFiles or sourceDirectory
tar -cvf name.tar sourceFiles
tar -cvf sourceDirectory/ - Verbosely create a tar file name.tar.gz from souceFiles and compress it use gzip
tar -czf name.tar.gz sourceFiles - Extract name.tar.gz from name.tar.gz
tar -xzf name.tar.gz - Extract one file test.txt from name.tar.gz
tar -xzf name.tar.gz test.txt - List archive members from name.tar
tar -tvf name.tar
Customize Linux Bash Envirenment
Configure .bashrc to customize user’s bash environment.
.bashrc file is locate in the user’s home directory. It contain lots of configurable items which can customize how the bash looks like and how user interactive with bash.
.bashrc file is locate in the user’s home directory. It contain lots of configurable items which can customize how the bash looks like and how user interactive with bash.
- Aliases could be configured under ‘#User specific aliases and functions’ in the .bashrc file. After add aliases item in the .bashrc file, user need log-off and log-in the system or restart bash by execute ‘bash’ command in the terminal to active the newly added aliases.
Aliases example: alias cls=’clear’ - Bash Prompt could be configured under ‘# Source global definitions’ in the .bashrc file. Environment variable $PS1 which could be change by PS1=’optionsPlusAnything’ is represent the bash prompt. The available options are as following
- \a an ASCII bell character (07)
- \d the date in “Weekday Month Date” format
- (e.g., “Tue May 26”)
- \e an ASCII escape character (033)
- \h the hostname up to the first `.’
- \H the hostname
- \n newline
- \r carriage return
- \s the name of the shell, the basename of $0
- (the portion following the final slash)
- \t the current time in 24-hour HH:MM:SS format
- \T the current time in 12-hour HH:MM:SS format
- \@ the current time in 12-hour am/pm format
- \u the username of the current user
- \v the version of bash (e.g., 2.00)
- \V the release of bash, version + patchlevel
- (e.g., 2.00.0)
- \w the current working directory
- \W the basename of the current working direc-
- tory
- \! the history number of this command
- \# the command number of this command
- \$ if the effective UID is 0, a #, otherwise a
- $
- \nnn the character corresponding to the octal
- number nnn
- \ a backslash
- \[ begin a sequence of non-printing characters,
- which could be used to embed a terminal con-
- trol sequence into the prompt
- \] end a sequence of non-printing characters
- Configure bash shell options with set/shopt
set -o check the current bash shell option setting
set -o bashOption to enable the bashOption
set +o bashOptioon to disable the bashOption
F-port Anti Virus for Linux
- Download F-port for Linux workstation from http://www.f-prot.com/products/home_use/linux/
- Extract the downloaded file to the user’s home folder use tar -xvf filename
- Enter the extracted folder execute ./install-f-prot.pl then type yes if system ask ln -fs /home/username/f-port/fpscan /usr/sbin/fpscan
- Preform a scan by execute fpscan /filepath/to/scan
Monday, June 07, 2010
Restore Ubuntu gnome panel
In the terminal execute following command to restore gnome panel to default setting.
$ gconftool-2 --shutdown
$ rm -rf .gconf/apps/panel
$ pkill gnome-panel
$ gconftool-2 --shutdown
$ rm -rf .gconf/apps/panel
$ pkill gnome-panel
Friday, June 04, 2010
Linux Permission and Owernship
File Permission
chmod permissionNumber fileName
File Ownership
chown userName fileName
chown userName.groupName fileName
chmod permissionNumber fileName
Owner | Group | Other Users | ||||||
Execute | Write | Read | Execute | Write | Read | Execute | Write | Read |
1 | 2 | 4 | 1 | 2 | 4 | 1 | 2 | 4 |
File Ownership
chown userName fileName
chown userName.groupName fileName
Subscribe to:
Posts (Atom)