Command Line Lesson 1 and 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

-t

$ ls -alt drwxr-xr-x 4 cc eng 4096 Jun 29 12:22 . -rw-r--r-- 1 cc eng 0 Jun 29 12:22 .gitignore drwxr-xr-x 5 cc eng 4096 Jun 30 14:20 .. drwxr-xr-x 2 cc eng 4096 Jun 29 12:22 satire drwxr-xr-x 2 cc eng 4096 Jun 29 12:22 slapstick -rw-r--r-- 1 cc eng 14 Jun 29 12:22 the-office.txt The -t option orders files and directories by the time they were last modified. In addition to using each option separately, like ls -a or ls -l, multiple options can be used together, like ls -alt. Here, ls -alt lists all contents, including hidden files and directories, in long format, ordered by the date and time they were last modified.

-l

$ ls -l drwxr-xr-x 5 cc eng 4096 Jun 24 16:51 action drwxr-xr-x 4 cc eng 4096 Jun 24 16:51 comedy drwxr-xr-x 6 cc eng 4096 Jun 24 16:51 drama -rw-r--r-- 1 cc eng 0 Jun 24 16:51 genres.txt The -l option lists files and directories as a table. Here there are four rows, with seven columns separated by spaces. Here's what each column means: Access rights. These are actions that are permitted on a file or directory. Number of hard links. This number counts the number of child directories and files. This number includes the parent directory link (..) and current directory link (.). The username of the file's owner. Here the username is cc. The name of the group that owns the file. Here the group name is eng. The size of the file in bytes. The date & time that the file was last modified. The name of the file or directory.

filesystem

1. The first directory in the filesystem is the root directory. It is the parent of all other directories and files in the filesystem. 2. Each parent directory can contain more child directories and files. Here blog/ is the parent of 2014/, 2015/, and hardware.txt. 3. Each directory can contain more files and child directories. The parent-child relationship continues as long as directories and files are nested.

cd

1. cd stands for "change directory". Just as you would click on a folder in Windows Explorer or Finder, cd switches you into the directory you specify. In other words, cd changes the working directory. 2. The directory we change into is 2015. When a file, directory or program is passed into a command, it is called an argument. Here the 2015 directory is an argument for the cd command. To move up one directory, use cd ...

SUMMARY

Congratulations! You learned how to use the command line to view and manipulate the filesystem. What can we generalize so far? Options modify the behavior of commands: ls -a lists all contents of a directory, including hidden files and directories ls -l lists all contents in long format ls -t orders files and directories by the time they were last modified Multiple options can be used together, like ls -alt From the command line, you can also copy, move, and remove files and directories: cp copies files mv moves and renames files rm removes files rm -r removes directories Wildcards are useful for selecting groups of files and directories

$ ls 2014 2015 hardware.txt

In the terminal, first you see $. This is called a shell prompt. It appears when the terminal is ready to accept a command. When you type ls, the command line looks at the folder you are in, and then "lists" the files and folders inside it. The directories 2014, 2015, and the file hardware.txt are the contents of the current directory.

-a

The -a modifies the behavior of the ls command to also list the files and directories starting with a dot (.). Files started with a dot are hidden, and don't appear when using ls alone. The -a is called an option. Options modify the behavior of commands. Here we used ls -a to display the contents of the working directory in more detail. In addition to -a, the ls command has several more options. Here are three common options: -a - lists all contents, including hidden files and directories -l - lists all contents of a directory in long format -t - order files and directories by the time they were last modified.

SUMMARY

The command line is a text interface for the computer's operating system. To access the command line, we use the terminal. A filesystem organizes a computer's files and directories into a tree structure. It starts with the root directory. Each parent directory can contain more child directories and files. - From the command line, you can navigate through files and folders on your computer: pwd outputs the name of the current working directory. - ls lists all files and directories in the working directory. - cd switches you into the directory you specify. - mkdir creates a new directory in the working directory. touch creates a new file inside the working directory.

mkdir

The mkdir command stands for "make directory". It takes in a directory name as an argument, and then creates a new directory in the current working directory.

mv

The mv command moves files. It's similar to cp in its usage. mv superman.txt superhero/ To move a file into a directory, use mv with the source file as the first argument and the destination directory as the second argument. Here we move superman.txt into superhero/. mv wonderwoman.txt batman.txt superhero/ To move multiple files into a directory, use mv with a list of source files as the first arguments, and the destination directory as the last argument. Here, we move wonderwoman.txt and batman.txt into superhero/. mv batman.txt spiderman.txt To rename a file, use mv with the old file as the first argument and the new file as the second argument. By moving batman.txt into spiderman.txt, we rename the file as spiderman.txt.

touch

The touch command creates a new file inside the working directory. It takes in a filename as an argument, and then creates an empty file in the current working directory.

*

cp * satire/ In addition to using filenames as arguments, we can use special characters like * to select groups of files. These special characters are called wildcards. The * selects all files in the working directory, so here we use cp to copy all files into the satire/ directory. cp m*.txt scifi/ Here, m*.txt selects all files in the working directory starting with "m" and ending with ".txt", and copies them to scifi/.

cp

cp frida.txt lincoln.txt The cp command copies files or directories. Here, we copy the contents of frida.txt into lincoln.txt.

pwd

pwd stands for "print working directory". It outputs the name of the directory you are currently in, called the working directory.

rm

rm waterboy.txt The rm command deletes files and directories. Here we remove the file waterboy.txt from the filesystem. rm -r comedy The -r is an option that modifies the behavior of the rm command. The -r stands for "recursive," and it's used to delete a directory and all of its child directories.


संबंधित स्टडी सेट्स

Test: Money Management (correct answers)

View Set

CA LIFE HEALTH INSURANCE - GUARANTEE EXAM

View Set

Chapter 9 heat transfer and change phase

View Set

Chapter 11: Solid Waste Generation & Disposal.

View Set

Marketing Research (Burns/Bush) - Final Ch 4, 5

View Set

Physics Semester 1 Final Johnson/Vining

View Set

Section 5: Contract Law in Texas

View Set