Command Line

¡Supera tus tareas y exámenes ahora con Quizwiz!

less

If you are viewing text files larger than a simple output, less is more. Use the following command to navigate through less: q - Used to quit out of less and go back to your shell. Page up, Page down, Up and Down - Navigate using the arrow keys and page keys. g - Moves to beginning of the text file. G - Moves to the end of the text file. /search - You can search for specific text inside the text document. Prefacing the words you want to search with / h - If you need a little help about how to use less while you're in less, use help.

history

In your shell, there is a history of the commands that you previously entered, you can actually look through these commands. Want to run the previous command without typing it again? Use !!. If you typed cat file1 and want to run it again, you can actually just go !! and it will run the last command you ran. Another history shortcut is ctrl-R, this is the reverse search command, if you hit ctrl-R and you start typing parts of the command you want it will show you matches and you can just navigate through them by hitting the ctrl-R key again. Once you found the command you want to use again, just hit the Enter key.

cp

Short for Copy. Let's start making some copies of these files. Much like copy and pasting files in other operating systems, the shell gives us an even simpler way of doing that. $ cp mycoolfile /home/pete/Documents/cooldocs mycoolfile is the file you want to copy and /home/pete/Documents/cooldocs is where you are copying the file to. You can copy multiple files and directories as well as use wildcards * the wildcard of wildcards, it's used to represent all single characters or any string. ? used to represent one character [] used to represent any character within the brackets $ cp *.jpg /home/pete/Pictures This will copy all files with the .jpg extension in your current directory to the Pictures directory.

mv

Stands for Move. Used for moving files and also renaming them.

ls

Stands for: list directory. The ls command will list directories and files in the current directory by default, however you can specify which path you want to list the directories of. Filenames that start with (.) are hidden, you can view them however with the ls command and pass the -a flag to it (a for all). There is also one more useful ls flag, -l for long, this shows a detailed list of files in a long format. you can add them both together with -la. The order of the flags determines which order it goes in, most of the time this doesn't really matter so you can also do ls -al and it would still work.

Relative path

This is the path from where you are currently in filesystem.

file

To find out what kind of file a file is, you can use the file command. It will show you a description of the file's contents. In Linux, filenames aren't required to represent the contents of the file. You can create a file called funny.gif that isn't actually a GIF.

Absolute path

a path that begins at the root and includes all successive subdirectories. Every time your path starts with (/) it means you are starting from the root directory.

touch

allows you to the create new empty files. Touch is also used to change timestamps on existing files and directories.

mkdir

make directory.

rm

remove a file. $ rm -f file1 -f or force option tells rm to remove all files, whether they are write protected or not, without prompting the user (as long as you have the appropriate permissions). $ rm -i file Adding the -i flag like many of the other commands, will give you a prompt on whether you want to actually remove the files or directories. $ rm -r directory You can't just rm a directory by default, you'll need to add the -r flag (recursive) to remove all the files and any subdirectories it may have. You can remove a directory with the rmdir command. $ rmdir directory

cat

short for concatenate, it not only displays file contents but it can combine multiple files and show you the output of them. It's not great for viewing large files and it's only meant for short content.

CD

stands for change directory. Shortcuts: $ cd . (current directory). This is the directory you are currently in. $ cd .. (parent directory). Takes you to the directory above your current. $ cd ~ (home directory). This directory defaults to your "home directory". Such as /home/pete. $ cd - (previous directory). This will take you to the previous directory you were just at.

pwd

this command means "print working directory" and it just shows you which directory you are in.


Conjuntos de estudio relacionados

AP Art History: Content Area 4, Later Europeans and Americas

View Set

PrepU 40: Fluid, Electrolyte, and Acid-Base Balance

View Set

Theorist 3 - John Dewey (1859-1952).

View Set

PSYC 319: Birth Options and Birth

View Set

Accounting test 6.1 (January 16 and 17)

View Set

Chapter 23 -give me liberty all study questions/ chronological

View Set

Alison McIntyre,"Doctrine of Double Effect,"

View Set

Term 1: Lesson 18 - Tracing Code

View Set