Description: Using the CentOS 6.7 Linux system on a VMware virtual machine, use a command-line interface. This article is mainly to record some of the learning process encountered in some of the problems and solutions, as is the Linux learning notes. (q is the problem, a is the solution)
Q: "Man" command not available, hint:-bash:man:command not found
A: No man manual is installed, use the command to install:
Yum Install-y man*
Q: Mount/dev/cdrom to a new file in the/mnt directory/CDR demo
A: Using the Mount command, the parameter is mounted and the target folder is mounted, as follows:
Mount/dev/cdrom/mnt/cdr
The unlocked command is "Umount", which is either a mounted device or one of the target folder mounts. You can use CDs if you are displaying "device is busy" when you hang up. Exit the current Mount directory, and then perform the Hang Up command. Q: Use the "cat" command to view files
A: Parameters can be viewed directly as file names, as follows:
Cat Helloworld.java
At the same time, you can also use the "tail", "NL", "head" and other commands, respectively, view the following lines, display line number to view the file, view the first few lines. Other parameters do not repeat, there is a need to check Google. Q: Management of System user account
A: New users use the "useradd" command to remove users using the "userdel" command, password management using the "passwd" command, as follows:
New user Sam, specifying its home directory as/usr/sam:
Useradd-d/usr/sam-m Sam
Delete user sam, option "-r" means deleting its home directory at the same time:
Userdel-r Sam
Manage passwords for users, including setting up, modifying passwords, and under root, passwd can use the option "-L" or "-u" to perform lock user and unlock user actions separately, and option "-D" to set the user password to null:
Passwd-l Sam
Passwd-u Sam
Passwd-d Sam
If you are under User rights, you can change the password by entering the "passwd" command directly. Q: Two ways to run a shell script
Open a text editor (you can use the Vi/vim command to create a file), a new file test.sh, the extension is SH (sh represents the shell), the extension does not affect script execution, if you use PHP to write a shell script, the extension will use PHP.
Enter some code, example:
#!/bin/bash
echo "Hello world!"
A:
1. As an executable procedure
Save the above code as test.sh and the CD to the appropriate directory:
chmod +x./test.sh #使脚本具有执行权限
./test.sh #执行脚本
Note that you must write./test.sh, rather than test.sh, run other binary programs as well, directly written test.sh,linux system will go to path to find there is no call test.sh, and only/bin,/sbin,/USR/BIN,/USR /sbin wait in path, your current directory is usually not in path, so write test.sh will not find the command, to use./test.sh told the system that it was looking in the current directory.
2. As interpreter parameter
This method of running is to run the interpreter directly, whose argument is the file name of the shell script, such as:
/bin/sh test.sh
/bin/php test.php
The script that runs this way does not need to specify the interpreter information in the first line, nor does it work.