Linux Command

Basic Commands for Ubuntu terminal Hi all, I’m Juanetebitel and we’ll see the basic commands Gnu-Linux Ubuntu for use in or on a console terminal (Applications – Accessories – Terminal) Also you may be interested in the following guide: 1. INTRODUCTION A shell is a program that takes user input, for example the commands you type, and translates it into instructions. We can compare it with the MS-DOS COMMAND.COM. To switch to text mode (command interpreter) from the graphical mode we have to press the key combinations: Ctrl + Alt + F1 or with: F2 F3 F4 F5 F6 This causes the system to exit the graphics mode and access any of the six Linux virtual consoles, to which can also be accessed when booting in text mode. To return to graphical mode you have to press Ctrl + Alt + F7 or Ctrl + Alt + F8 (According to graphic mode session we want to return). Besides being an interactive interpreter commands that you type, the shell is also a programming language, which allows us to write scripts that allow multiple commands together in a file. Similar to batch files in MS-DOS. Links of interest: GNU Emacs, Manuals Online A quick introduction to GNU Emacs Two. BASICS In a terminal: Applications with names hyphenated compounds between words (eg compizconfig-settings-manager). For blanks bottom gets a hyphen (eg filename) When we put several commands in a row, to run at a time, leave a space between them, never a comma (eg avidemux kde-i18n k3b k3b-i18n-is). When you type a command, the shell follows a series of steps: 1. Find the name of the order and check if it is a builtin. Two. Checks if the command is an alias, ie a substitute name of another order. Three. Failure to meet any of the above, find the appropriate program and runs it. April. If the shell can not find the order that we typed, displays an error message. The general format of a command on Linux is: command [-options] [arguments] When you type the command must take into account the following characteristics: • The commands have to type them exactly. • Uppercase and lowercase letters are considered different. • In its most common form, the operating system uses a $ sign as a prompt to indicate that it is ready to accept commands, although this character can be easily replaced by another or others chosen by the user. In the event that the user accesses as administrator this sign is replaced by #. • When necessary to enter the name of a file or directory as an argument to a command, Linux, to write the first letters of it and hits a autorrellenado pressing the tab key. If it can not distinguish between different cases filled to the point at which they differ. The Terminal keeps a HISTORY and you can see how it works: April. BASIC COMMANDS ls -> list: list. It shows the contents of the folder you indicate later. It is the first command that every Linux user should learn. Eg. If you want to show us what’s in / etc: $ Ls / etc If we do nothing interpret what we see is the contents of the folder where we are today: $ Ls Also accepts certain arguments that may be interesting. To show all files and folders, including hidden: $ Ls-a To display the files and folders along with the rights you have, what occupies, etc: $ Ls-l Besides the arguments may overlap. If we wanted to display the files in the same way as before, but also showing hidden: $ Ls-la cd -> change directory: change directory. We can use it with absolute or relative paths. In the absolute we indicate all the way from the root (/). For example, wherever we are, if we write in console … $ Cd / etc / apt … Bring us into this folder directly. Similarly if we write … $ Cd / … We sent to the root filesystem. Relative paths are relative to something, and that something is the folder where we are today. Imagine you are in / home, and we go to a temporary folder called within your personal folder. With write … $ Cd tu_carpeta / temporal … Will stand there. As you can see we have overlooked the / initial home because if they introduce it draws on the directory where you are, that’s that. What happens if you type only … $ Cd Yes, just “cd”. What this does is it takes you directly to your personal folder and wherever we are. It’s really very practical, very simple and that not everyone knows. mkdir -> make directory: make directory. Create a folder with the name that you indicate. Again we can use absolute and relative paths. We can tell you the whole path to the directory preceding it we want to create, or if we are in the folder that will contain just enough to put the name: $ Mkdir / home / your_account / cucumber If you are in / home / your_account … $ Mkdir cucumber rm -> remove: delete. Delete the file or folder that you indicate. As before you can enter the full path and file name. This from now we will ignore, I think it has become clear with the two previous commands. To delete a file: $ Rm filename To delete an empty folder: $ Rm foldername To delete a folder containing files and / or other folders that may contain even more: $ Rm-r foldername Other options: “-f” does not ask for confirmation to delete or “-v” will show what is fading. To delete a directory: $ Rmdir dirname cp -> copy: copy. Copy the file indicated where you say. Here we can also play with the routes, both for the source file, as in the destination. You can also put the name you want to put the copy. For example, if we were in / etc/X11 and would like to make a backup of xorg.conf in our personal folder: $ Cp xorg.conf / home / tu_carpeta / xorg.conf.backup mv -> move: move. Same as above, only instead of making a copy, move directly the file with the name that you indicate, may be other than the original: $ Mv / etc / pepino.html / home / tu_carpeta / ese_pepino.html Another very practical use that can be given is to rename a file. Simply enter the new name in the second argument with the same path of the first. In this example we assume that we are in the folder that contains: $ Mv pepino.html ese_pepino.html find -> find: find. Find the file or folder that you specify: $ Find /-name cucumber The above command would look everywhere folders and files called cucumber. If we were sure that is located in / var for example, I indicaríamos: $ Find / var-name cucumber If we’re not sure of the name can indicate it with wildcards. Suppose we seek name contains “pepi” in the same folder as before: $ Find / var-name * pepi * You have other options. For example we can tell you find files / folders over 1500 KB: $ Find /-size +1500 Or the files / folders containing the name “pepi” and have less than 1000 KB: $ Find /-name *-size cucumbers * -1000 clear -> clear: clear. Clear the screen / console quedándola like we just open it. $ Clear ps -> process status: status of the processes. It shows us what we want to know about the processes running on your system. Each process is identified by a number called PID. If we … $ Ps-A … Will show a list of all processes, their PID to the left and to the right name. If you want more information: $ Ps aux kill -> kill: kill. Kill the process we indicate with PID: $ Kill Sometimes the process does not “die” at all, but you can force the system to safely kill him as follows: $ Kill -9 sudo -> super-user do: do as root. The user account in Ubuntu is relatively normal. Administrator has rights to half. I mean, it does, but every time you do something important and risk to the system, it must be done by the prefix “sudo” and then typing the password. For example, something we’ve done many times in the tutorials is to make a backup of the xorg.conf file. It is located in the / etc/X11 and that any user can make changes or delete anything if you are not an administrator or have rights as such, thanks to sudo. So we always did: $ Sudo cp / etc/X11/xorg.conf / etc/X11/xorg.conf Whenever we need to make a apt-get/aptitude update or install and actions of this type, we have to put before the “sudo” passwd -> password: password. With this command you can change the password for our account. First we asked the current password as a security measure. After you are prompted for twice the new password. $ Passwd su -> super-user: root. (Although the su command is usually associated with “super user” really seems to be coming from “switch user” or “substitute user”) Through its we loguearnos as superuser. After writing it will ask for the root password and we as administrator. We can do anything we want. $ Su This command also allows you to login with a different account. For example, imagine we have another account, besides root and ours, called “guest”. To login as such would be sufficient to: $ His guest and then enter the password for that account. sudo passwd -> you can change the password for root (the super-user). It is not a command itself (is the union of 2) but it is interesting that you know him. $ Sudo passwd apt -> advanced packets tool: advanced package tool. It is one of the most useful commands that have been developed on GNU / Linux debian or based on this distro. It allows us to check for updates, update the entire system. It also offers functionality to search, download and install packages with a single order. Have variants, the most used are: $ Apt-cache search package_name Search packagename to see if there is literal or about offering packages that could be in case you have put a name approximate. $ Apt-get update Upgrade repositories are those containing the packages. Repositories are the addresses that contain our packages. apt-get update does is update the list of all those packages, with the direction of where to get them so that when making the subsequent search and download faster so in our computer. $ Apt-get upgrade Update our system with all possible updates that might occur. The upgrade is not only on the operating system itself, but also about the applications that are contained in the repositories. A useful way to stay up to date. $ Apt-get install package_name Located the package name you want to download and install, this command will manage the process. Look in our index (which is created with update) from where to download the package, and then do not install it. $ Apt-get remove [- purge] package_name Removes the specified package system. Damite the argument “-purge” (brackets = optional) to also delete the configuration files. $ Apt-get autoremove Remove packages that have become unusable after making some apt-get remove, so-called orphans. Normally after making the latter a message warns you that you make. All these commands require administrative privileges, so if you use them as root, you must first add the known “sudo”. aptitude -> aptitude: aptitude, ability. In the background plays with the apt acronym to create aptitude. It is an improved version of apt. If you noticed in all the manuals and entrances where there was an installation process I used aptitude instead of apt. The second is perhaps the most widespread to be the one that was born first. aptitude was born as a front-end for apt, ie as a kind of graphic application and text mode for all you do apt. But the truth is that its features are better. apt when you install something you can make a suggestion to install anything else you might come in handy, but it does not. There are programs that also use other for some of its features or options. apt does not install the latter, as much you warn. But yes it will install aptitude because he knows that somehow it is essential for you order. In the same way, if you install with apt then that program is used by another, when you uninstall the primary, the secondary will not be uninstalled, though it no longer makes much sense to be installed, and the same goes for libraries. aptitude is able to uninstall what you installed himself as a recommendation. Dont let the system cleaner after uninstalls. To open the graphical interface of aptitude, you only have to type it: $ Aptitude However, it also can be used exactly like apt, but with the features that I mentioned aptitude: $ Aptitude search packagename $ Aptitude install package_name $ Aptitude remove packagename $ Aptitude purge packagename $ Aptitude update $ Aptitude upgrade And as before, you will need to use sudo in front if you are not as administrator. dpkg -> depackage: despaquetar. When installed packets undergo a process of despaquetaje. In the background a. Deb package contains a number of scripts pre-installation and post-installation files within the package. This command will use it to install a package. Downloaded deb we already have in our system. In many cases there is an application that is not in the repositories and have downloaded the. Deb to install the appropriate GUI (GDebi in the case of GNOME). Basically these graphical interfaces are based on dpkg. If we want to install a package and downloaded via console will use the argument ‘-i’ (i = install): $ Dpkg-i packagename To uninstall ‘-r’ (r = remove): $ Dpkg-r package_name To remove the package and configuration files “-purge” (purge): $ Dpkg-r-purge packagename Alien -> Alien: from another country, from another planet. Although Debian-and Ubuntu-extension has a huge number of packages in its repositories, someone may have some trouble finding a specific application packaged as interested but has seen the package you want for other distros. alien is quite handy for these situations by allowing us to transform a package from a package manager determined in another. For example we can pass from one. Deb (Debian) a. Rpm (Red Hat) and vice versa. The extensions are supported: * Deb (Debian) * Rpm (Red Hat) * Slm (Stampede) * Tgz (Slackware) * Pkg (Solaris) Its use is simple. What we know is the argument that will transform the original package in the target extension: * “-To-deb” or “-d” to transform. Deb * “-To-rpm” or “-r” to transform. Rpm * “-To-tgz” or “-t” to transform. Tgz * “-To-pkg” or “-p” to transform. Pkg * “-To-slp” to transform. Slp As an example, we’ll have a course Red Hat package called “pepino.rpm” to “pepino.deb”: $ Alien-d pepino.rpm man -> Manual: manual. This is another powerful commands in linux. Program or command is normally comes with a complete help file on their use and their arguments. When desconozcáis how it is used and what arguments have a command or application you only have to type in console: $ Man named Sometimes the information you provide us man can become excessive. Almost all commands and pipeline applications accept the argument “- help” or “-h” to display more summarized some help. For example with aptitude: $ Aptitude – help $ Aptitude-h All commands that I have shown you have many more arguments. I have set the most used or required, so if there are any that you are particularly interested in knowing more about him, you have “man” or “- help” for more details. Link: Spanish give the command “man” passwd – We can change the password using the passwd command. We asked the old password (current) and the new. Return to ask a second time to validate new. The root user can change the password of any other user. However, only privileged users can change their own password. Syntax: passwd date – the screen shows the day and time, enabling also the change thereof. Syntax: date [options] [format] cal – displays a calendar of current month or year. Syntax: cal [month] [year] Eg • cal calendar shows the current month. • cal 1949 shows the calendar year 1949. • lime in May 1945 shows the May 1949 calendar. who – Which users have the computer at the time, in which terminal are and what time the session started. Syntax who whoami – Tells the user who is working on the current terminal. Syntax: whoami finger – Presents comprehensive information of users connected to the network. Syntax: finger [-bfilpqsw] [login1 login2] uname – Provides the name of the system on which you are working. Syntax: uname [-options] As main options are: -A further indicates the version, date and type of processor. -M also indicates the type of processor. -R also indicates the version. -V further indicates date. logname – Indicates the name of the user connected to the system (which you are logged on). Syntax: logname info – Provides help for a command summary in question. Syntax: info [command] clear – This command is used to clear the screen. Syntax: clear echo – Displays on screen the arguments you give it. Syntax: echo [arg1] [argument2] … [ArgumentoN] alias – Assigns a name or label to the execution of a command with its options. Syntax: alias tag = ‘order’ The only alias command shows all aliases that are created. The unalias command removes the specified alias. May. WILDCARD CHARACTERS OR wildcards An important feature of most shell in Linux is the ability to refer to more than one file. One way to do this is using special characters called wildcards. As in MS-DOS, the wildcard * means any character or string of characters in the file name. The shell will replace the asterisk with all possible combinations from the files in the directory to which we are referring. It is said that you are performing a wildcard expansion. The? is also a wildcard, but only expands a character. With both characters there is an exception. Not affect those files that begin with a dot, and are hidden commands like ls. We may also use brackets to indicate a set of characters or While a range of ASCII characters. Examples: $ Ls * n * displays all files and directories in the current directory containing the character n $ Ls * lists all files and directories in the current directory $ Ls tm? displays all files and directories in the current directory that begin with tm and contain three characters $ Ls table [123] to display all the files and directories in the current directory that begin with table, followed by character 1, 2 or 3, and end in a $ Ls?? Basis [AZ] [5-9] * displays all files and directories in the current directory that begin with any two characters followed by chain basis, then a capital letter followed by a number from 5 to 9 and finally a character string (one, several or none) June. RELATED COMMANDS DIRECTORY Staff Directory As seen above, the directory is a directory with a specific name assigned to a user. Home directories are usually subdirectories of / home (in some cases is used mnt, or other lower order subdirectory). Generally the name matches the username, but can not, and multiple users can be working in the same directory. Every Linux user can create a tree structure of subdirectories and files as complex as you want under your home directory but usually never out of it. ls Displays the contents of a directory. ls displays the names of files and subdirectories contained in the directory being. Only obtained names files without any further information. Syntax: ls [-options] [file] -A Displays all files including some that usually are hidden from the user (those beginning with a dot). Recall that the point file. indicates the current directory and double point .. the parent directory, which contains at present. -L This is the long list option displays all the information about each file including: protection, size and creation date or last ambio introduced, … -C Displays sorting by date and time of creation. -T Displays sorting by date and time of modification. -R Displays the directory and sorts in reverse order. -R List subdirectories also. ls subdir Displays the contents of the subdirectory subdir. -L filename Displays all information about the file filename. – Color Displays the directory contents colored. The above options can be combined. Eg ls-cr Displays directory inversely ordered by date. The ls command supports or replacement characters * and?. Eg ls *. gif Displays all file names ending in. gif, for example, dib1.gif, a.gif, etc.. ls file? Lists all files whose names begin with file and have a five-character name, for example: file1, file2, filea, etc.. mkdir mkdir (make directory) allows each user to create a new subdirectory. Syntax: mkdir subdirectory where subdir is the directory name to be created. rmdir This command deletes one or more directories of the system (remove directory), provided that these subdirectories are empty. Syntax: rmdir subdirectory For example, rmdir subdir1 where subdir is the name of the directory to be deleted. This command cd to change directory from the current working directory. Syntax: cd [directory] Here are some options: cd – changes to the last directory you were before today. cd .. changes to the parent directory. cd. leaves us where we are. cd puts us back into the user’s home directory. cd / root directory changes Note: unlike Linux MS-DOS cd there is no way .. no space between cd and the colon. pwd The pwd (print working directory) displays or prints the directory path in which we are at this time. This command is one of the few that does not have options and is used by simply typing pwd. July. ACCESS DISK DRIVES: INSTALLATION AND REMOVAL Unlike Windows Linux does not use letters (“a”, “c”, “d:”, …) to access the different drives of a computer. In Linux to access the contents of a disk drive or CD-ROM that must have been previously “mounted”. The mounting is done using the mount command, so that the contents of the unit is available to the user in the directory of Linux you choose. The syntax of this command is as follows: mount [-t tipo_de_sistema_ficheros] [device] directorio_de_montaje For example to access the CD-ROM would type the following command: mount-t iso9660 / dev / cdrom / mnt / cdrom where-t iso9660 indicates the type of system that uses the disk drive to store the files (the most common are: iso9660 in the case of a CD-ROM, vfat in the case of Windows, and ext2 (3 or 4) in For Linux), / dev / cdrom indicates the device is to be mounted. All devices are represented by a file in the / dev, for example, in the case of a disk will probably / dev/fd0, last / mnt / cdrom is the directory in which the user will provide content CD-ROM. To mount floppy disks usually use the directory / mnt / floppy (although this depends on the version of Linux that we use). In the case of Ubuntu, the mount command directly support the / cdrom, / cdrom1, / floppy, … for the assembly of our units, so all you would have to write, to ride for example because the drive would be: mount / floppy If you omit the filesystem type and / or device, Ubuntu takes the information from the file / etc / fstab, which contains information on the various computer file systems. Anyway, the user can always create an empty directory with the name you choose to mount the drives you want where you want. When the user has stopped using that disk must “dismantle” using the umount command before removing the floppy disk or CD-ROM. Following the example of the drive in Ubuntu, you would type: umount / floppy In principle, to use the mount command specifying all parameters need to be an administrator or root. For a common user to use floppy disks, CD-ROM, etc.. need to edit the file / etc / fstab. For example so that any user can access a floppy will indicate the following line: / Dev/fd0 / mnt / floppy vfat user, noauto 0 0 Will also make sure that the directory / mnt / floppy is accessible by all users. After following the above steps anyone can “mount” a disk by typing the following command: mount / mnt / floppy As before, the user must execute the command umount / mnt / floppy before removing the diskette. Note: There are currently distributions (eg SuSE Linux) that perform this process automatically, so the floppy and CD-ROM are accessible to all users in a simple way, using the commands: mount / mnt / floppy umount / mnt / floppy provided that / mnt / floppy is the appropriate path. To remove a partition we use the command “umount”: sudo umount / dev / sdxx Where “xX” is the partition you want to remove. Eg. “Sda5” which is the partition “5” hard disk “a” August. ORDERS RELATED FILES cp Copy a file or files to another file or directory. Syntax: cp file1 [file2] … [FileN] target where [ficheroX] is the file to copy and [destination] is the destination file or directory. We can use. and .. to refer to the current directory and parent directory respectively. Thus, the command cp file1 file2 makes a copy of file1 and file2 called. If file2 does not exist, create it with the same attributes of file1. If file2 existed before its contents are destroyed and replaced by the file1. The file file2 will be in the same directory as file1. Both file1 and file2 show the name of a file, you can include the path to it if any of them is not in the current directory. Another possibility is: cp file1 file2 namedir making copies of file1 and file2 in directory namedir. mv is used for moving and renaming files. Syntax: cp file1 [file2] … [FileN] target As seen, this command has a shape similar to above. The mv command performs the same function as the cp but also destroys the original file. So, if we execute the order mv file1 file2 ultimately moves the contents of file1 to file2; User purposes he has done is to rename file1, file2 calling. Similarly, mv file1 file2 namedir moving one or more files (file1, file2, …) conservándoles namedir directory name. The command, namedir1 mv namedir2 rename the subdirectory namedir1 by namedir2. It is emphasized that the mv command likewise serves to rename files. Deleting files rm. This command deletes one or more files in a directory which we have permission. Syntax: rm file1 [file2] This command is very easy to delete useless files, and unfortunately also useful. Therefore it is desirable and almost essential to use the-i option, as follows: rm-i file1 file2 With this option, Linux will ask for confirmation to delete each file in the list, of if you really want your destruction or not. We recommend always using this command with this option to prevent deletion of files useful. For example, if you type rm-i superfluous is displayed the following message: remove superfluous? and, answer y (yes) or N (not). In this command you can use wildcard characters (* and?), For example, rm fich * would delete all files in the current directory that begin fich. The command rm * deletes all files in the current directory. Another option is-r, which deletes directories recursively (delete the directory and all its contents). file This command performs a series of checks in a file to try to classify, showing its features. Syntax: file file After executing this command displays the type of file and information about it. This command can also be applied to directories. Viewing cat without a file format. This command displays the content one or more non-formatted files. It also allows you to copy one or more files as an appendix to an existing one. Some ways to use this command are the following: Saca cat filename display the contents of the file filename. cat file1 file2 Saca on screen, sequentially and in the order specified, the contents of each given file. cat> file1 Accept what is entered from the keyboard and stores it in file1 (creates file1). To finish used d Viewing pr format files. 9. 9.2. 9.3. and .. hello bye 1. Two. Three. 10. Introduction group. 11. Introduction $ méndez luque Rodriguez méndez Rodriguez $ b. Examples: 12. Introduction Examples: Examples: Eg Eg :!






Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s