Got it

Common Linux Commands

Latest reply: Apr 10, 2019 09:36:54 510 1 2 0 0

This topic describes the common Linux commands. For VCN500

Listing Files

ls -la: lists all files in the current directory, including the hidden files whose names start with dot (.).

ls a*: lists all files whose names start with the letter a in the current directory.

ls -l *.doc: lists all files ended with .doc in the current directory.

Copying Files

cp fileA fileB: copies the fileA file to the fileB file.

cp fileA /home/bible/: copies the fileA file from the current directory to the /home/bible/ directory.

cp * /tmp: copies all unhidden files in the current directory to the /tmp/ directory.

cp -a fileA fileB: recursively copies the fileA directory, including all its files, to the fileB directory.

Searching for File Contents

grep bible /etc/fileA: searches for lines containing bible in the fileA file.

Searching for Files

find -name "*.rpm": searches for RPM packages in the current directory.

find | grep page: searches for files whose names contain page in the current directory and its sub directories.

Editing Files

vi /etc/bubby.txt: opens the /etc/bubby.txt file using the vi command.

Moving and Renaming Files

mv fileA fileB: Renames the fileA file to fileB.

mv fileA /tmp: moves the fileA file in the current directory to /tmp/.

Deleting Files and Directories

rm fileA: deletes the fileA file.

rm *: deletes all files in the current directory. However, the current directory is not deleted.

rm -rf floderA: deletes the floderA directory, including all its files.

rm -i a*: deletes all files whose names start with the letter a in the current directory. Each time a file is deleted, the system prompts you to confirm the deletion.

Switching Directories

cd ~: switches to the home directory.

cd /tmp: switches to the /tmp directory.

Creating Directories

mkdir floderA: creates a floderA directory in the current directory.

mkdir -p /tmp/floderA: creates a sub directory in the current directory.

Deleting Directories

rmdir: deletes an empty directory.

Mounting and Unmounting Contents

mount /dev/hdc /tmp/floderA/disk1: mounts the device files to disk1.

umount /tmp/floderA/disk1: unmounts the device files from disk1.

Viewing Routing Tables

netstat -nr: views the routing table.

Viewing Service Port Status

netstat -an|less: views the server port status.

Restarting the Tomcat

/etc/init.d/novell-tomcat4 restart: restarts the Tomcat when plug-ins have been installed in iManager.

Modify Permissions on Files

chmod abc fileA: modifies permissions on the fileA file.

In this command, ab, and c are the number representations of the permissions you want to set. a represents the permissions for the file owner, b represents the permissions for the group, and c represents the permissions for other users. Read access is the number 4, write access is 2, and execute access is 1. These numbers can be added together to get the right permission for that class.

  • To change the permissions on the fileA file to rwx, make sure that the number is 7 (7 = 4 + 2 +1).
  • To change the permissions on the fileA file to rw-, make sure that the number is 6 (6 = 4 + 2).
  • To change the permissions on the fileA file to r-x, make sure that the number is 5 (5 = 4 + 1).

Deleting ED Instances

ndsconfig rm: deletes ED instances.

Synchronizing Time

  1. rcxntpd stop: disables the NTP service.
  2. ntpdate: shortens the time difference.
  3. rcxntpd start: enables the NTP service.

Viewing Ports Provided by the Local Host

netstat: lists the connected services.

netstat -a: lists the connected services and those that are being listened on.

netstat -an: lists the connected port numbers and those that are being listened on.

netstat -ap: After running the netstat -an command, you can run the netstat -ap command to list the connected process IDs. You can run the kill command to kill a process. For example, you can run the kill -9 111 command to kill process 111.

df Command

df (abbreviation for disk free) is a standard Unix computer program used to display the amount of available disk space for file systems on which the invoking user has appropriate read access.

Syntax: df [options]

The options are as follows:

  • -a: displays the disk space usage of all file systems, including the file systems that have 0 blocks, for example, the /procfile system.
  • -k: displays output in KB.
  • -i: displays information about node i.
  • -t: displays the disk space usage of the file systems of a specified type.
  • -x: displays the disk space usage of the file systems that are not of the specified type.
  • -T: displays the file system type.

free Command

The free command is used to display information about unused and used memory and swap space on any computer running the Linux operating system.

Syntax: free [-b | -k | -m]

The options are as follows:

  • -b: displays output in bytes.
  • -k: displays output in KB.
  • -m: displays output in megabytes (MB).

sync Command

The sync command is used to write any data buffered in memory out to disk.

shutdown Command

The shutdown command can be used to securely shut down and reboot the Linux operating system. Each time the system is shut down using this command, the system displays a warning message to all users. You can also specify a time point or time segment for shutting down the operating system. The time point is in hh:mm format, in which hh is the hour and mm is the minute. The time segment is in +m format, in which m is the number of minutes to wait. After executing the shutdowncommand, the system automatically synchronizes data on the disk with the memory.

Syntax: shutdown [options] [time] [warning message]

The options are as follows:

  • -k: The operating system is not really shut down. Only a warning message is sent to all users.
  • -r: The operating system immediately reboots after shutdown.
  • -h: The operating system does not reboot after shutdown.
  • -f: The operating system skips fsck upon reboot.
  • -n: The operating system is shut down without initiating the init program.
  • -c: A running shutdown command is canceled.
  • Only root user can run the shutdown command

date Command

The date command is used to display the system date and time.

cal Command

The cal command is used to display the calendar.

Syntax: cal [options] [Month [Year]]

The options are as follows:

  • -j: displays Julian dates (days one-based, numbered from January 1).
  • -y: displays a calendar for the current year.

echo Command

The echo command is used to output status text to the screen or a file.

Syntax: echo [-n] [character string]

-n: displays a new-line character.

  • If the character string is enclosed in double quotation marks (""), the original character string is displayed.
  • If the character string is not enclosed in double quotation marks (""), each word in the character string is displayed and separated by a space.

rm Command

rm (short for remove) is used to remove objects such as files, directories, device nodes, and symbolic links from the file system.

Syntax: rm [options] [directories] filenames

The options are as follows:

  • -b: displays output in bytes.
  • -k: displays output in KB.
  • -m: displays output in MB.
  • rm -r: deletes directories.
  • rm -f: deletes files without requiring confirmation by the user.


good share knowledge
View more
  • x
  • convention:

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.