Linux/unix mac Command Notes

Source: Internet
Author: User
Tags rsync

BG and FG

Linux/unix the biggest advantage of the Microsoft platform is the real multi-user, multi-tasking. Therefore, in the task management also has the characteristic management thought.
We know that on Windows, we either have a program running in the background as a service or stop the service. Instead of allowing the program to switch between foreground and background. Linux provides FG and BG commands that allow you to easily schedule tasks that are running.

Suppose you find that a program running in the foreground takes a long time, but you need to do something else, you can hang up the program with Ctrl-z, and then you can see the system prompt:
[1]+ stopped/root/bin/rsync.sh
Then we can schedule the program to execute in the background: (the number behind BG is the job number)
#bg 1
[1]+/root/bin/rsync.sh &
Use the Jobs command to view the tasks that are running:
#jobs
[1]+ running/root/bin/rsync.sh &
If you want to bring it back to the foreground, you can use
#fg 1
/root/bin/rsync.sh
This way, you can only wait for the task to complete on the console.


File Management

1. Create a Directory

Mkdir

NO1. Create a level directory in the current path

[Email protected] root]# mkdir test

NO2. Create a multilevel directory on the current path

[Email protected] root]# mkdir-p mytest/test1/test1_1

NO3. Assigning permissions to a new directory while creating a directory

[Email protected] root]# mkdir-m 777 Testmod

So that anyone has any permissions on this directory

2. Copying files and folders

Cp

NO1. Copy files from the specified directory to the current directory, and rename

[email protected] root]# CP ~/.BASHRC Bashrc_bak

NO2. Forces the file of the specified directory to be copied to the current directory, regardless of whether the current directory contains the file

[Email protected] root]# cp-f ~/.BASHRC BASHRC

NO2. Copy the specified directory to the current directory

[Email protected] root]# cp-r/root/test.

[Email protected] root]# cp-r/root/test/.

As a result, when you copy a directory, the last level of the source path is copied all over, including itself.

NO3. Copy files from the specified directory to the specified directory

[email protected] root]# CP ~/.BASHRC/BAK/.BASHRC

NO4. Copies all the properties of the source file as it is copied. If you do not specify a parameter, the destination file may be inconsistent with the source file properties.

[Email protected] root]# cp-a ~/.BASHRC/BAK/.BASHRC

NO5. If two folders to ensure synchronization, one file changed, another file is changed, but to ensure that two files are up to date.

[Email protected] root]# cp-u/SRC/.BASHRC/BAK_SRC/BASHRC

3. Create link files, including hard links and soft links

ln

NO1. Create a shortcut similar to Windows

[Email protected] root]# ln-s test.txt Test.txt_slnk

NO2. When you want to back up a file, but not enough space, you can create a hard connection for the file. This way, even if the original file is deleted, the

The linked file was not deleted, but it was not deleted in the storage space.

[Email protected] root]# ln-l test.txt Test.txt_hlnk

4. deleting files

Rm

NO1. Delete the current directory file

[Email protected] root]# RM test.txt

NO2. Force delete the current directory file, do not eject the hint

[Email protected] root]# rm-f test.txt

NO3. Force removal of entire directory, including directory and file deletion, requires Administrator privileges

[Email protected] root]# rm-r-F test

5. Delete a folder

RmDir

NO1. Delete an empty directory

[Email protected] root]# rmdir emptydir

NO2. Delete a multilevel empty directory

[Email protected] root]# rmdir-p emptydir/d1/d11

6. Mount file system and Unmount file system

Mount/umount

NO1. Mount Optical Drive

[Email protected] root]# mount-t Iso9660/dev/cdrom/mnt/cdrom

NO2. Mount Optical drive, support Chinese

[Email protected] root]# mount-t iso9660-o codepage=936,iocharset=cp936/dev/cdrom/mnt/cdrom

NO3. Mount Windows partition, FAT file system

[Email protected] root]# mount-t Vfat/dev/hda3/mnt/cdrom

NO4. Mount the Windows partition, NTFS file system

[Email protected] root]# mount-t ntfs-o Iocharset=cp936/dev/hda7/mnt/had7

No5. Mount ISO File

[Email protected] root]# Mount-o Loop/abc.iso/mnt/cdrom

NO6. Mount Floppy Drive

[Email protected] root]# Mount/dev/fd0/mnt/floppy

NO7. Mounting Flash Disk

[Email protected] root]# Mount/dev/sda1/mnt/cdrom

NO8. To mount a folder shared by Windows operating systems

[Email protected] root]# mount-t smbfs-o username=guest,password=guest//machine/path/mnt/cdrom

NO9. displaying mounted file systems

[email protected] root]# mount

[[email protected] root]# cat/etc/fstab display system boot automatically loaded file system

[[email protected] root]# Cat/etc/mtab Displays the file system currently loaded

7. Check disk space

Df

NO1. Displays all storage-system space usage while displaying the storage system's file system type S

[Email protected] root]# Df-at

NO2. Displays space usage for the specified file system

[Email protected] root]# df-t ext3

NO3. humanized display of the size of each storage space

[Email protected] root]# Df-ah

NO4. Sometimes mount the network file system, if only want to see the local file system with the following command

[Email protected] root]# df-ahlt

NO5. View disk usage for a file system

[Email protected] root]# df-h/dev/cdrom

8. Check the size of the directory space

Du

NO1. View the current folder size

[Email protected] root]# Du-sh

NO2. View the size of subfolders contained in the current file and file

[Email protected] root]# Du-ch

NO3. To view the size of a file

[Email protected] root]# du-h test1.txt

NO4. View the size of multiple files at the same time

[Email protected] root]# du-h test1.txt test2.txt

9. Disk Defragmentation

LINUX is basically not defragmented, and it automatically organizes it every once in a while.

10. Create/Change File system

NO1. Create File system type

[Email protected] root]# UMOUNT/DEV/SDB1

[Email protected] root]# mkfs-t EXT3/DEV/DB1

[Email protected] root]# Mount/dev/sdb1/practice

11. Change file or folder permissions

chmod

sudo chmod 600xxx (only the owner has read and write permissions)

sudo chmod 644xxx (owner has read and write permissions, group user only Read permissions)

sudo chmod 700xxx (only the owner has read and write and Execute permissions)

sudo chmod 666xxx (everyone has access to read and write)

sudo chmod 777xxx (everyone has access to read and write and execute)

chmod go-rwx Test set his own notes to be seen only by himself.

Linux/unix

Restart Apache: sudo apache2ctl restart Mac:sudo apachectl restart

Crawl files:curl URL > xxx

Copy file contents without formatting pbcopy < ~/.ssh/id_rsa.pub

copy the native files to the remote server
#scp/home/administrator/news.txt [Email protected]:/etc/squid
/home/administrator/absolute path to local files

Copy the files on the remote server to the native
#scp [Email Protected]:/usr/local/sin.sh/home/administrator

For more information, refer to: http://www.itqun.net/content-detail/136575.html

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.