Você está na página 1de 5

Linux Commands

who: Linux who command shows who is logged on to the system. This is a useful command for a Linux system administrator because they can check how many users currently logged in the system and who they are. who am i: who am i shows the ID of current user echo: It is typically used in shell scripts and batch files to output status text to the screen or a file. set: Displays, sets, or removes environment variables. Syntax SET [variable=[string]] Specifies the environment-variable name. Specifies a series of characters to assign to the variable.

variable string

Type SET without parameters to display the current environment variables. Type SET variable= without a value to delete variable from the environment. Type SET variable=value to assign value to variable. We can use %variable% in batch files whenever you need its value.

cat: This is used to display text files on screen


Copy text files Combine text files

Create new text files Syntax Copy $ cat oldfile.txt > newfile.txt

Displaying Text $cat filename

Combine text files cat file1 file2 > newcombinedfile Create new files $cat foo.text write text after pressing enter (to save and exit press ctrl+D) Mkdir:this command is used to create directory Rmdir:this command is used to remove the director ls:Lists the contents of a directory
ls

l :this would list each of the files in the current directory and the files permissions, the size of the file, date of the last modification, and the file name or directory. Below is additional information about each of the fields this command lists.

ls ~ :List the contents of your home directory by adding

a tilde after the ls command ls / :List the contents of your root directory. ls ../ :List the contents of the parent directory.

Pwd: Short for print working directory, pwd is a Linux command to print the directory you're currently working in when at the command line. cd: Changes the directory Syntax cd [directory] wc: Short for word count, wc displays a count of lines, words, and characters in a file Example-wc Ankit.txt Displays information about the file myfile.txt. Below is an example of the output. 5 13 57 myfile.txt

5 = Lines 13 = Words 57 = Characters PATH: In UNIX / Linux file systems, the human-readable address of a resource is defined by PATH. On Unix / Linux like operating systems, (as well as on DOS / Windows and its descendants), PATH is an environment variable listing a set of paths to directories where executables may be found man: The man command is short for manual and provides in depth information about the requested command or allows users to search for commands related to a particular keyword whatis: whatis searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output. Only complete word matches are displayed dir: used to list directory contents uname: print name of current system date: tells us the date and time in Linux date '+DATE: %m/%d/%y%nTIME:%H:%M:%S'

Would list the time and date in the below format. DATE: 02/08/01 TIME:16:44:55 cal: calendar for the month and the year Syntax cal [month] [year] bc: Calculator cp: Copies files from one location to another example: cp /Downloads/Ankit.txt Templates/Ankit.txt copies the Ankit.txt file into the templates directory rm: Deletes a file without confirmation. mv: Renames a file or moves it from one directory to another directory. df: Report how much free disk space is available for each mount you have. apropos: apropos searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output awk: Short for Aho, Weinberger, and Kernighan, awk is a script processing language also known as oawk, gawk, mawk and nawk allows for pattern scanning and processing. chown: Command for system V that changes the owner of a file. example: chown chope file.txt Give permissions as owner to user chope for the file file.txt clear: used to clear the command prompt cmp: Compares two files and tells you what line numbers are different. comm: Select or reject lines common to two files

grep: Finds text within a file sed: Sort for Stream Editor sed allows you to use pre-recorded commands to make changes to text. exit: Allows you to exit from a program, shell or log you out of a Unix network

Você também pode gostar