miércoles, 15 de enero de 2014

Linux command

Delete a file - rm command syntax

rm (short for remove) is a Unix / Linux command which is used to delete files from a filesystem. Usually, on most filesystems, deleting a file requires write permission on the parent directory (and execute permission, in order to enter the directory in the first place). The syntax is as follows:
rm -f -r {file-name}
Where,
  • -f: Forcefully remove file
  • -r: Remove the contents of directories recursively

Remove or Delete a File

To remove a file called abc.txt type the following command:
$ rm abc.txt
To remove all files & subdirectories from a directory (MS-DOS deltree like command), enter:
$ rm -rf mydir
To remove empty directory use rmdir and not rm command:
$ rmdir mydirectory


How do I Find Out Linux CPU Utilization?

Whenever a Linux system CPU is occupied by a process, it is unavailable for processing other requests. Rest of pending requests must wait till CPU is free. This becomes a bottleneck in the system. Following command will help you to identify CPU utilization, so that you can troubleshoot CPU related performance problems.
Finding CPU utilization is one of the important tasks. Linux comes with various utilities to report CPU utilization. With these commands, you will be able to find out:
* CPU utilization
* Display the utilization of each CPU individually (SMP cpu)
* Find out your system's average CPU utilization since the last reboot etc
* Determine which process is eating the CPU(s)

Old good top command to find out Linux cpu load

The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
The top command monitors CPU utilization, process statistics, and memory utilization. The top section contains information related to overall system status - uptime, load average, process counts, CPU status, and utilization statistics for both memory and swap space.

Top command to find out Linux cpu usage

Type the top command:
$ top
Output:
Delete / Remove a Directory Linux comand
rmdir command - Deletes the specified empty directories.
rm command - Delete the file including sub-directories.

Syntax- rmdir command
The rmdir command remove the DIRECTORY(ies), if they are empty. The syntax is:
rmdir directory-name
rmdir [option] directory-name

Examples

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command to remove a directory called /tmp/docs:
 
rmdir /tmp/docs
 
If a directory is not empty you will get an error:
$ rmdir letters


HowTo: Use grep Command In Linux / UNIX – Examples


How do I use grep command on Linux, Apple OS X, and Unix-like operating systems? Can you give me a simple examples of the grep command?
The grep command is used to search text or searches the given file for lines containing a match to the given strings or words. By default, grep displays the matching lines. Use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. grep is considered as one of the most useful commands on Unix and other Linux operating systems.


Did you know?

The name, "grep", derives from the command used to perform a similar operation, using the Unix/Linux text editor ed:
g/re/p

The grep command syntax

The syntax is as follows:
 
grep 'word' filename
grep 'word' file1 file2 file3
grep 'string1 string2'  filename
cat otherfile | grep 'something'
command | grep 'something'
command option1 | grep 'data'
grep --color 'data' fileName
 

How do I use grep command to search a file?

Search /etc/passwd file for boo user, enter:
$ grep boo /etc/passwd
Sample outputs:
foo:x:1000:1000:foo,,,:/home/foo:/bin/ksh
You can force grep to ignore word case i.e match boo, Boo, BOO and all other combination with the -i option:
$ grep -i "boo" /etc/passwd
The grep command is used to search text or searches the given file for lines containing a match to the given strings or words. By default, grep displays the matching lines. Use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. grep is considered as one of the most useful commands on Unix and other Linux operating systems.


Did you know?

g/re/p
The grep command syntax

grep 'word' filename
grep 'word' file1 file2 file3
grep 'string1 string2' filename
cat otherfile | grep 'something'
command | grep 'something'
command option1 | grep 'data'
grep --color 'data' fileName

How do I use grep command to search a file?$ grep boo /etc/passwd
Sample outputs:
Sample outputs:
foo:x:1000:1000:foo,,,:/home/foo:/bin/ksh$ grep -i "boo" /etc/passwd

No hay comentarios:

Publicar un comentario