×

You are here: Home > FAQ > Commonly used commands in Linux

FAQ

Commonly used commands in Linux

LS # default display a list of files in the current directory
ls -a # show all files, including hidden files
ls -l # Display file properties, including size , date, symbolic links, whether read and write, and whether the executable
ls --color = never * .so> obj # does not display the text color, so all the documentation to obj file

cd dir # to switch to the dir directory of the current directory
cd / # to switch to the root directory
cd .. # switch to the to the parent directory
cd ../ .. # switch to the second level directory
cd ~ # to switch to the user directory, such as the root user, then switch to the / root

RM File # delete a file
rm - fr dir # delete the current directory called dir's entire catalog

Source target # cp copy of the file source target
cp / root / Source. # will / root files under source copied to the current directory
cp -av soure_dir target_dir # copy the entire directory, two directories exactly like
cp -fr source_dir target_dir # copy the entire directory, and is non-linked copy, when the source directory with the symbol link, the two are not the same directory

target # mv Source renamed the file source target

diff dir1 dir2 # compare two directory file a directory list is the same, but it does not compare the actual contents of the file, the different lists
diff file1 file2 # compare file a file if the contents of two of the same If the file in text format, it will not display the same content, if it is expressed in binary code only two files are different
comm file1 file2 # compare files, display the contents of two files are not the same

echo message # Display string of characters
echo "message message2" # display is not continuous string
Cat:
Cat File # display the contents of the file, and DOS-type the same
cat file | more # Display the contents of the file and transmitted to more procedures to achieve paging display, use the command less file can achieve the same functionality
more # paging commands, usually through the pipeline will pass its contents, such as LS | More

LC_ALL = zh_CN.GB2312 # The LC_ALL environment variable is set to the value of export zh_CN.GB2312
export DISPLAY = 0: 0 # With this setting, the current character terminal run graphics programs can be directly running Xserver
Date # Display the current date and time
date -s 20:30:30 # Set the system time is 20:30:30
Date -s 2002-3-5 to 2003-3-5 period # Set the system
clock -r # right Bios system reads the time parameters
clock -w # The system time (as set by the date time) write Bios

off CDROM eject #umout and CD eject, but not in a busy state cdrom, otherwise invalid

du # computing capacity of the current directory
du -sm / root # computing / root Capacity directory and M units
find -name / path file # in the / path directory to find the file to see if there File
grep -ir "chars" string chars # Find all files in the current directory, and ignore case, - i is the case, -r for the next one directory

vi to edit files File File #
vi original basic use and command:
Enter the command mode to press ctrl + c, then enter: x (exit) ,: x (exit and save):! w (write files) ,: w (do not ask the way to write files),:! r file (read document file) ,:% s / oldchars / newchars / g (all strings oldchars replaced newchars) to operate this type of command

man LS # read about the ls command to help
man ls | grep color # read about the ls command help and find color string in which the program through grep

startx # running Linux graphical environments have
Xfree86 # only run X Graphics Server

restart the computer reboot #
halt # Turn off the computer
init 0 # Close all applications and services into pure operating environment
init 1 # restart the application and service
init 6 # Restart your computer