Linux Questions and Answers

Table of contents

No heading

No headings in the article.

Q1: Check your present working directory.

pwd

Q2: List all the files or directories including hidden files.

ls -la

Q3: Create a nested directory A/B/C/D/E

mkdir -p A/B/C/D/E

Q4: To view what's written in a file.

cat <filename>

Q5: To change the access permissions of files.

chmod 700 <filename>

700 means grant read, write, and execute access to file.txt.

Q6: To check which commands you have run till now.

history

Q7: To remove a directory/ Folder.

rm -r <directoryName>

-r means recursively delete directory contents.

Q8: To create a fruits.txt file, add content(One in each line) -Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava and finally view the content.

Q9: To show only top three fruits and only bottom three fruits from the file.

Q10: To find the difference between two file.

diff <file1> <file2>