Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, 25 September 2012

sed 去掉windows下的回车符

用 sed 去掉 去掉windows下的回车符
 (注意^M 在linux 下写法 按^M 是回车换行符,输入方法是按住CTRL+v,松开v,按m)
sed -i 's/^M//g' df.txt  

Monday, 27 February 2012

usermod command

usermod command

the default path of the command is /usr/sbin

add one user to one group:
here use the option '-a'

from the manul
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups

/usr/sbin/usermod -a -G group1 user_name

remove one user from one group, you have to move that user to another group:
/usr/sbin/usermod -G group2 user_name

Monday, 16 May 2011

my thinking after reading Ubuntu Pocket Guide and Reference

It took me sometime to finish reading this book:
Ubuntu Pocket Guide and Reference


It's nice especial for the beginners.

You can download here for free.

How to get your wireless card working under Linux?
“Getting the card to work is simple! Just grab the
source code for the module and compile it against
the kernel. insmod it and then use iwconfig to configure a
WEP password—”

That's why Linux was “for techies only“.
Now it's so easy.

Desktop Linux systems changed everything.
Ubuntu is one of them.
If you can use Windows, you can use Ubuntu.
For it free, safe, faster and ease of use. why not use Linux? 

chapter 1 installation 
Skip, for It's really easy now, just follow the steps.

chapter 2 Configuring Ubuntu 
Every major area of hardware. Make them works.

chapter 3 Getting to grips with the desktop
The basic knowledge to use this desktop.

chapter 4 Users and the filesystem
The purpose of this chapter is tell you the file& folder:
 names, paths, permissions, locations...

chapter 5 Hands‐on at the command‐line
From zero to hero studying Shell/Bash in this chapter. It's great, not too hard, and contain lots of useful commands, suitable for the beginners. I wrote a PPT to introduce bash to the beginners, I felt that PPT is so ugly after I read this chapter. I can get more information from this book to update my PPT when needed. 


chapter 6 Software management
Almost tells the two tools: the Advanced Packaging Tool (APT), and the Debian Package system (dpkg), and use APT or dpkg installing/uninstalling packages.
This chapter also introduces the: software repositories. I only want to say: "change it to get the best download speed!"

chapter 7  Securing the system
This chapter tells you:
How to use  Update Manager to update the system? need it ?
Configuring the firewall.
Need an antivirus program? I don't think so, Linux is much safer than Windows even without an antivirus program.

From this book, I got the name of some books I want to read:

The Pragmatic Programmers -- Ubuntu Kung Fu
www.pragprog.com/titles/ktuk/ubuntu‐kung‐fu
Paper Book ($34.95)
eBook ($22.00) 
too expensive for me...


Free Software Magazine, published in a free PDF
edition roughly every two months and covering matters relating to the
world of Free Software, including but not limited to Linux. www.freesoftwaremagazine.com.

Wednesday, 4 May 2011

Practice Trac on CentOS 5 x86_64

Trac is written in the Python programming language(Open Source)

Python: python-2.4.3-43.el5
Database: SQLite  (python-sqlite-1.1.7-1.2.1)
Version Control System: Subversion  (subversion-1.6.11-7.el5_6.3)
Web Server: Apache (httpd-2.2.3-45.el5.centos)

Creating a Project Environment:
After install, create a new environment using trac-admin: 
#trac-admin /path/to/myproject initenv 
make sure the apache can access project folder
#chown -R apache.apache /path/to/myproject
  
Trac Configuration File:
My <projectenv> /var/trac/test/
The Trac Configuration File: /var/trac/test/conf/trac.ini
Changes to the configuration are usually reflected immediately, though changes to the [components] or [logging] sections will require restarting the web server. You may also need to restart the web server after creating a global configuration file when none was previously present.
See the details of all the sections here.

Install plugins:
Download the source and run "python ./setup.py bdist_egg" and
copy the resulting .egg file from the "dist" directory to the
"plugins" directory of your Trac project.

enable the plugin is done in the [components] section of the configuration file, for example, enable tractoc plugin:

[components]
tractoc.* = enabled

Note: After installing the plugin, you need to restart your web server. 
#sudo /etc/init.d/httpd restart

Wednesday, 5 January 2011

Time in Linux programming

Kernel measures the passage of the time in three different ways:

  1. Wall time ---> measuring absolute time
  2. Process time
  3. Monotonic time ---> calculating relative time

    Unix systems represent absolute time as the number of elapsed seconds since the epoch, which is defined as 00:00:00 UTC on the morning of 1 January 1970.
    SO, even absolute time is, at a low level, relative time.

    The following table shows some useful functions for uing time:
Name second Microsecond Nanosecond
Getting the current time of day time() gettimeofday() clock_gettime()
Setting the current time of day stime() settimeofday() clock_settime()
Sleeping sleep() usleep() nanosleep()

Now Microsoft, ipod nano are in my mind, are these names from here? So interesting.

With a 32-bit long type, time_t will let us have the Y2K mess all over again --- in 2038!

and "Come 22:14:07 on Monday, 18 January 2038, most systems and software will be 64-bit." said Robert Love. Will these happen, let's go and see.

POSIX Clocks have four of the linux standard time source:

  • CLOCK_MONOTONIC
  • CLOCK_PROCESS_CPUTIME_ID
  • CLOCK_REALTIME
  • CLOCK_THREAD_CPUTIME_ID

Tuning the system clock

example by a Makefile

make looks at the file modification timestamps of the source file versus the object file. If the source file is newer than the object file, make rebuilds the source file into an updated object file.If the source file is not newer than the object, however, no action is taken

Tuesday, 28 December 2010

basic git command

git is the fast version control system

Now I am studying how to use git

  • Here are the commands for common using:
  1. Use git clone to check out sources. i.e. Download pulseaudio sources:
    git clone git://git.0pointer.de/pulseaudio.git
    
  2. Use git status to show your working tree status
    git status
    
  3. Use git pull to update the codes to the newest version
    git pull origin master
    
  4. Add or edit your file
  5. Commit your new file
    git add your-file
    
    git commit -m 'log'
    
  6. Push your change to remote repository
    git push origin master
    

  • Here is a sample to generate a patch
    git status
    
    view /home/usr/.gitconfig 
    
    git add src/pulsecore/random.c
    
    git log -v
    
    git commit -m 'core: Fix variable "has_whined" value bug'
    
    git format-patch -s -1
    
    view 0001-core-Fix-variable-has_whined-value-bug.patch