Basic cygwin operation commands

Source: Internet
Author: User
Tags echo message

Cygwin basic operation command: ---------------------------- ls # display the current directory file list by default ls-a # display all files, including hidden files ls-l # display file properties, including size, date, symbolic connection, whether it can be read and written, and whether it can be executed ls -- color = never *. so> obj # do not display the text color. Record all so files to the obj file ------------------------------------------------------------ cd dir # Switch to the dir directory cd/# under the current directory to the root directory cd .. # Switch to the upper-level directory cd .. /.. # Switch to the upper-level directory cd ~ # Switch to the user directory, such as the root user, switch to/root to restore rm file # delete a certain file rm-fr dir # Delete the entire directory named dir under the current directory unzip cp source target # copy the file source as targetcp/root /source. # copy the file source under/root to the current directory cp-av soure_dir target_dir # copy the entire directory. The two directories are exactly the same cp-fr source_dir target_dir # copy the entire directory, in addition, it is replicated in non-link mode. When the source directory contains When the symbolic link is used, the two directories are not the same. Why mv source target # rename the file source to target 1_diff dir1 dir2 # compare whether the file list in directory 1 and directory 2 is the same, but do not compare the actual content of the file. If the difference is true, list diff file1 file2 # compare whether the content of file 1 is the same as that of file 2. If it is a text file, different contents are displayed. If the binary code is used, the two files are different comm file1 file2 # Compare files, and different contents of the two files are displayed -------------------------------------------- -------------------------- Echo message # display a string of characters echo "message message2" # display a discontinuous string cat: cat file # display the file content, similar to DOS type cat file | more # display file content and transfer it to the more program for paging display. Use the command less file to implement the same function. more # paging command, generally, the content is transmitted to the MPs queue, such as ls | more than export LC_ALL = zh_CN.GB2312 # Set the environment variable LC_ALL to zh_CN.GB2312export DISPLAY = 0: 0, the graphics program running on the current character terminal can run directly on Xserverdate # display the current date Date-s 20:30:30 # set the system time to 20: 30: 30 date-s 2002-3-5 # set the system period to 2003-3-3-5clock-r # Read The Time Parameter clock-w in the system Bios # set the system time (such as the time set by date) write Bios ------------------------------------------------------------------------ eject # Remove the CDROM and bring it up, but the cdrom cannot be in the busy state, otherwise, the capacity of the current directory is calculated as du-sm/root # and the capacity of the/root directory is calculated. find-name/path file in MB # search in the/path directory check whether there are files Filegrep-ir "chars" # search for the character string chars in all files in the current directory and ignore the case.-I is case sensitive, -r is the directory of the next level. Prepare vi file # edit the file filevi basic usage and command: press ctrl + c to enter the command: x (exit),: x! (Exit and save): w (Write File),: w! (Write files without inquiry),: r file (Read file),: % s/oldchars/newchars/g (replace all strings with newchars) this type of command is used to operate man ls # Read help man ls about ls command | grep color # Read help about ls command and use the grep program to find the color string ---------------------------------------------------------------------- startx # run Linux graphics environment Xfree86 # Run only X Graphics server ------------------------------------------------------- --------------- Reboot # restart the computer halt # disable the computer init 0 # disable all applications and services, enter the pure operating environment init 1 # restart the application and service init 6 # restart the computer ---------------------------------------------------------------------- extended command ------------------------------------------------------------------------------------------------------------------------------- ------------- tar xfzv file. tgz # file the file. tgz decompress tar xfzv file. tgz-C target_path # file the file. decompress tgz to tar Tar cfzv file in the get_path directory. tgz source_path # compress the file source_path to file. tgztar c directory> directory.tar pack directory directoryinto uncompressed directory.tar gzip directory.tar # overwrite the original file to generate compressed directory.tar.gz gunzip directory.tar.gz # overwrite the original file to decompress and generate uncompressed directory.tar. Tar xf directory.tar # decompressed files can be decompressed into dmesg # display kernle startup and driver loading information uname # display operating system type uname-R # display operating system kernel version policstrings file: displays the ASCII characters in the file ---------------------------------------------------------------------- rpm-ihv program. rpm # Install program and display the installation process rpm2targz program. Rpm program. tgz # convert rpm files to tarball-format ‑su root # Switch to Super User sulogin/dev/tty4 # Wait for the user to log on or directly log on to tty4, that is, alt + F4, and enable a shellchmod a + x file # Set the file to executable, the script file must be set like this, otherwise, you must use bash file to execute chmod 666 file # Set the file to read/write chown user/dir # Set the/dir directory to all the users mknod/dev/hda1 B 3 1 # create block settings Backup hda1, master device number 3, Slave Device number 1, that is, the first partition of the master disk mknod/dev/tty1 c 4 1 # create a character device tty1, master device number 4, the public device number is 1, that is, the first tty terminal ------------------------------------------------------------------ touch/tmp/running # create a temporary file running under/tmp, restart and disappear ------------------------------------------------------------------------ sleep 9 # Wait for 9 seconds until lpd stop or cups stop # stop Printing Service Program lpd start or cups start # start printing service program lpd restart or cups restart # restart printing service program lpr file.txt export print file file.txt restart fdisk/dev/hda # It is like executing the fdisk of dos cfdisk/dev/hda # is more friendly than the fdisk interface. mount-t ext2/dev/hda1/mnt # Load/dev/hda1 to the/mnt directory df # display file system Loading mount-t iso9660/dev/cdrom/mnt/cdrom # load the optical drive to the/mnt/cdrom directory mount-t smb // 192.168.1.5/1_dir/mnt-o Username = tomlinux, password = tomlinux # load the shared directory of windows to the/mnt/smb directory. the username and password are all tomlinuxmount-t nfs 192.168.1.1: /dirdir/mnt # load the shared directory of the nfs service into the/mnt/nfs Directory umount/mnt # uninstall the/mnt directory, the/mnt directory must be in the idle state. umount/dev/hda1 # unmount the/dev/hda1 device. The device must be in the idle state of sync # synchronize the content in the cache with the disk, copying a file in Linux usually requires the system to be idle before writing the file e2fsck/dev/hda1 # Check whether/dev/hda1 has a file system error, prompt repair method e2fsck-p/dev/hda1 # Check for/dev/hda1 errors. If yes, automatically fix e2fsck-y/dev/hda1 # Check errors. All questions Run e2fsck-c/dev/hda1 in the yes mode # Check whether the disk has a bad partition mkfs/dev/hda1 # format/dev/hda1 as the ext2 format mkfs. minix/dev/hda1 # format/dev/hda1 as the file system in minix format mfks/dev/hda9 # format/dev/hda9 as the Linux swap format swapon/dev/hda9 # convert swap partition loading as memory to use swapoff/dev/hda9 # unmount the swap partition ---------------------------------------------------------------- lilo # Run the lilo program, the program automatically finds/etc/lilo. and follow the configuration to apply lilo-C/root/lilo. conf # lilo program Press/root/lilo. conf configuration takes effect grub # in Linux sh Run the boot loader setup program grub-install # install the grub disk boot program. After the boot loader is successfully installed, you do not need to restart the system like lilo to upgrade the kernel. You only need to modify/etc/grub. conf to implement the new boot configuration rdev bzImage # display the root partition information of the kernel rdev bzImage/dev/hda1 # Set the root partition of the kernel to/dev/hda1, this is important in systems that do not have boot programs such as lilo. ---------------------------------------------------------------------- dd if =/dev/fd0 f = floppy. fd # copy the content of a floppy disk into an image. The function is the same as that of hd-copy commonly used in the Old Stone Age. dd if =/dev/zero f = root. ram bs = 1024, count = 1024 # generate a block Device of 1 MB, which can be treated as hard A partition of the disk to use mkfs root. ram # format the block device into the ext2 format dd if = root. ram f =/dev/ram0 # Set init. rd format root. import ram content to the memory mount/dev/ram0/mnt # ramdisk/dev/ram0 and load it to the/mnt directory -------------------------------------------------------------- gcc hello. c # Set hello. c compilation became famous as. out binary execution file gcc hello. c-o hello # Set hello. the gcc-static-o hello. c # Set hello. c compiled the binary static execution file ldd program that became famous as hello # display which libraries the program uses objcopy-S program # Remove the symbol table in the program and useless debugging information, which can be much smaller than javasstrace netscape # trace the execution of the program netscape, view the called library, environment variable settings, configuration files, and devices used, other applications called, etc. In strace, what the program does is clear at a glance. Ps # display the current system process information ps-ef # display all processes in the system kill-9 500 # killall-9 netscape is killed by the program numbered 500 # name all netscape program killing, kill is not omnipotent. It is ineffective for zombie programs. Top # display the activity of system processes and CPU resources by percentage free # display the system memory and swap usage time program # after the program ends, the time used for running the program will be calculated ------------------------------------------------------------------------ chroot. # Switch the root directory to the current directory, use chroot/tomlinux when debugging the new system # Switch the root directory to the/tomlinux directory chroot/tomlinux sbin/init # Switch the root directory to/tomlinux and run sbin/initadduser id # Add userdel id of the user named id # Add userlist of the user named id # display the list of logged-in users passwd id # change the user id password passwd-d root # Delete the password of the root user c Hown id/work # specify the/work directory as the id. The User owns the specified ifconfig eth0 192.168.1.1 netmask 255.255.255.0 # Set the IP address 192.168.1.1 For nic 1 and the mask is 255.255.255.0, if you do not write the netmask parameter, the default value is 255.255.255.0ifconfig eth0: 1 192.168.1.2 # The second address of bundled Nic 1 is 192.168.1.2ifconfig eth0: x 192.168.1.x # bind Network Card 1 with the second address 192.168.1.xifconfig down eth1 # disable the second network card so that it stops working hostname-F tomlinux.com # Set the host name to tomlinux.com Route # display current route settings route add default gw 192.168.1.1 metric 1 # Set 192.168.1.1 as the default route del default # Delete the default route dhcp # Start dhcp Service dhclient # Start dhcp Terminal and automatically obtain the IP address ping 163.com # test the connection with 163.com ping 202.96.128.68 # test and IP 202. 96.128.68 connection supervisor probe rtl8139 # Check whether the driver rtl8139.o works properly lsmod # Show the mounted driver insmod rtl8139.o # load the driver rtl8139.oinsmod sb. o io = 0x280 irq = 7 dma = 3 dma16 = 7 mpu_io = 330 # load the driver and set the relevant irq, dma parameter rmmod rtl8139 # Delete the driver module gpm-k named rtl8139 # Stop the mouse service gpm-t ps2 in the character state # enable the mouse service for the ps2 type in the character state --------------------------------------------------------------------- -Telnet 192.168.1.1 # telnet server with logon IP address 192.168.1.1 to telnet iserver.com # telnet server with login domain name iserver.com to ftp 192.168.1.1 or ftp iserver.com # log on to the ftp service Linux development Common commands (cygwin environment is also) cygwin Experience 1. access Windows Drive cd/cygdrive/ccd c: 2 in cygwin. integrate the cygwin command to Windows. If cygwin is installed on d:/develop/cygwin, run tar czvf xxx under d:/develop/cygwin/secrets. tgz./ Basically, all commands can be used, including ls, more, less, find, grep, and so on. 3. use the TGZ backup to add the BIN of cygwin to the PATH to create a BAT file: @ echo offd: cd d:/website/8 thmanagetar czvf 8thmanage. tgz 8thmanage4. in Windows, run the SHELL script to add the BIN of cygwin to PATH and create a script t under the/var/directory of $ CYGWIN. sh, note, t. the paths in sh are relative to $ CYGWIN, and you need to access drive c. Use/cygdrive/c/to run: d:/cygwin/bin/bash d in Windows: /cygwin/var/t. sh (can be executed regularly) 5. synchronize the Windows system user mkpasswd-l>/etc/passwdmkgroup-l>/etc/group. If Domain exists, add-d domainname6. install the system service cygrunsrv7.cygwing and use rsynca. Install rsync component B. go to cygwin and configure the Server vi/etc/rsyncd. conf... screts file =/etc/tom. ipaddr. for details about the pas configuration file, refer to another rsync article I wrote. Note: The Password File Permission must be 0400 chmod 0400/etc/tom. ipaddr. pasc. start the server rsync -- daemond. the client is synchronized under cygwin of the client and runs rsync synchronization. For more information about the commands, see rsync. 8. use SSHDa in cygwin. cygrunsrc and opensshb must be installed. run ssh-host-config-y and press enter until CYGWIN = is displayed. Enter tty ntsec and press Enter. (Alternatively, add the system environment variable CUGWIN = nesec tty) c. if the SSHD service has been installed in your Windows service, you can directly start and close it in the service. (Cygrunsrc-S sshd or net start sshd) 9. Chinese display vi ~ /. Bashrc # enable the ls and dir commands to display Chinese characters and colors. alias ls = 'ls -- show-control-chars -- color 'Alias dir = 'dir-N -- color' # Set it to a Chinese environment., make the prompt "Chinese export LANG =" zh_CN.GBK "# output as Chinese code export OUTPUT_CHARSET =" GBK "~ /. Inputrc: set completion-ignore-case onset meta-flag onset output-meta. onset convert-meta. offcygwin. bat: @ echo offset MAKE_MODE = UNIX

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.