Commands - Review Flashcards
(275 cards)
Search which subdirectories are in a directory that match a word.
Linux
ls -la /locationtosearch | grep wordtomatch
Find files with a specific word.
Linux
grep -rw /home/user/Downloads -e “vacation”
How do you search for a word in multiple files
L
grep study *_notes.txt
grep fruit *.txt (search for fruit in a group of text files)
grep fruit apple.txt banana.txt orange.txt
How do you search for a word in a file. L
grep oranges fruit.txt
To create a new file with default permissions L
touch test_file.txt
How do you create/modify a text file using the popular text editor that can be found on nearly all Linux distributions?
nano my_file
Can create and modify a text file in the command line
To make a text file in Linux with a redirector
cat > (name of file)
ENTER key, then type text, then save file with CTRL + D
Find files with a specific word L
grep -rw /home/user/Downloads -e “vacation”
**having issues with this one, it won’t find my “file” files in a subdirectory
What’s the main way I should use to search for which subdirectories or files match a word? L
ls -la /locationtosearch | grep wordtomatch
L: options available for a command
(command) –help
extra information about commands - manual pages
Linux
man (command)
long list format (something is too long, make it readable and organized with this command, more detail)
Linux
-l
show all files in a directory and hidden files flag
Linux
-a
hide a file or directory
Linux
.(in front of file or directory)
current directory
pwd
change directory 3 ways
cd
cd ..
cd ~
make a new directory
mkdir
copy a file/directory 3 ways
cp filename.ext location
pattern copies: cp *.png ~/Desktop
directory copies (inside contents): cp -r ‘Cat Pictures’ ~/Desktop
moving a file
mv filename.txt locationtomoveto
to make a text file with a redirector and enter text right away
cat > (name of file)
ENTER, type text, save with CTRL +D
view text files 2 ways
l/w
cat
less
-g
-G
-/word_search
-q
more (windows)
flags/parameters that can be used with cat when to view certain lines? 2
-Head Line#
-Tail Line#
modifying text file (create a new one with nano) and enter text right away
nano my_file
how do you search for a word in one file?
linux
grep word filename.ext