
touch [filename] - create a new filepwd - print working directorycd - change directory
ls
-a - lists all contents, including hidden files and directories
-l - lists all contents of a directory in long format
|
|
1.==Access rights==. These are actions that are permitted on a file or directory.
2.==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 (.).
3.==The username of the file’s owner==. Here the username is cc.
4.==The name of the group that owns the file==. Here the group name is eng.
5.The ==size== of the file in bytes.
6.The ==date & time== that the file was ==last modified==.
7.The ==name== of the file or directory.
-t - order files and directories by the time they were last modified.-alt - multiple options are used together
cp
-[filename1] [filename2]- copy the contents of filename1 into filename2.-[filename1] [filename2] [path]- a new copy of filename1 and filename1 in [path] directory.-*- copy all files-m*.txt- copy all files starting with “m” and ending with “txt”
mv
-[filename1] [filename2]- rename a file
rm
- The rm command deletes files and directories.
- The
-ris 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. - Be careful when you use
rm! It deletes files and directories permanently.
cat > >> <
echo "Hello" > hello.txt- The>command redirects the standard output to a file.cat hello.txt- Thecatcommand outputs the contents of a file to the terminal.cat oceans.txt > continents.txt->takes the standard output of the command on the left, and redirects it to the file on the right. Note that - ->overwrites all original content in continents.txt.cat glaciers.txt >> rivers.txt->>takes the standard output of the command on the left and appends (adds) it to the file on the right.cat < lakes.txt-<takes the standard input from the file on the right and inputs it into the program on the left.cat volcanoes.txt | wc-|is a “pipe”. The|takes the standard output of the command on the left, and pipes it as standard input to the command on the right.wc-wccommand outputs the number of lines, words, and characters in volcanoes.txt, respectively.sort lakes.txt-sorttakes the standard input and orders it alphabetically for the standard output.uniq- filter out adjacent, duplicate lines in a file.
grep
grep Mount mountains.txt-grepstands for “global regular expression print”. It searches files for lines that match a pattern and returns the results.
grep -i- be case insensitive.grep -R- searches all files in a directory and outputs filenames and lines containing matched results. -R stands for “recursive”grep -Rl- searches all files in a directory and outputs only filenames with matched results. -R stands for “recursive” and l stands for “files with matches”.
sed
sed 's/snow/rain/[g]' forests.txt-sedstands for “”. It accepts standard input and modifies it based on an expression, before displaying it as output data. It is similar to “find and replace”.
s- stands for “substitution”. it is always used when using sed for substitution.snow- the search string, the text to find.rain- the replacement string, the text to add in place.
the above command will only replace the first instance of “snow” on a line.g- means “global”
~/.bash_profile is the name of file used to store environment settings. It is commonly called the “bash profile”. When a session starts, it will load the contents of the bash profile before executing commands.
- The
~represents the user’s home directory. - The
.indicates a hidden file. - The name ~/.bash_profile is important, since this is how the command line recognizes the bash profile.
- The command
nano ~/.bash_profileopens up ~/.bash_profile in nano. - The text
echo "Welcome, Jane Doe"creates a greeting in the bash profile, which is saved. It tells the command line toechothe string “Welcome, Jane Doe” when a terminal session begins. - The command
source ~/.bash_profileactivates the changes in ~/.bash_profile for the current session. Instead of closing the terminal and needing to start a new session,sourcemakes the changes available right away in the session we are in.




近期评论