Basic Terminal Commands

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In the Linux command line, what is the purpose of the tty command?

  • To print the file system name.
  • To display the current date and time.
  • To print the file name of the terminal connected to standard input. (correct)
  • To list all users currently logged in.

What information does the w command provide?

  • The current date and time, formatted in UTC.
  • The amount of free disk space on the system.
  • A summary of system uptime, logged-in users, and load averages. (correct)
  • A list of all files and directories in the current directory.

What is the function of the cal command in Linux?

  • To change file permissions.
  • To display a calendar for a specified month or year. (correct)
  • To calculate mathematical expressions.
  • To set system-wide environment variables.

What does the command date '+%Y' output?

<p>The current year in full format (e.g., 2024). (B)</p> Signup and view all the answers

What is the purpose of the pwd command?

<p>To print the present working directory. (B)</p> Signup and view all the answers

What does the command ls do in the Linux file system?

<p>Lists the contents of the current directory. (A)</p> Signup and view all the answers

What is the effect of the ls -a command?

<p>Lists all files, including hidden files. (B)</p> Signup and view all the answers

What does the output drwxr-xr-x at the beginning of a line in ls -l command indicate about a file?

<p>It is a directory with read, write, and execute permissions for the owner, and read and execute permissions for the group and others. (B)</p> Signup and view all the answers

Which command is used to change the current directory in the Linux command line?

<p>cd (B)</p> Signup and view all the answers

Which command is used to remove a directory in Linux?

<p>rmdir (D)</p> Signup and view all the answers

If rm command cannot remove a directory, what can you infer?

<p>The directory is not empty. (A)</p> Signup and view all the answers

What command creates an empty file?

<p>touch (A)</p> Signup and view all the answers

What does the command cat test12.txt do?

<p>It displays the content of <code>test12.txt</code> on the terminal. (D)</p> Signup and view all the answers

What does echo "Hello">test12.txt accomplish?

<p>Overwrites <code>test12.txt</code> with the content &quot;Hello&quot;. (B)</p> Signup and view all the answers

What is the difference between > and >> when redirecting output?

<p><code>&gt;</code> overwrites, <code>&gt;&gt;</code> appends. (D)</p> Signup and view all the answers

After running the commands echo "Hello">test12.txt and then echo "World">>test12.txt, what will be the content of test12.txt?

<p>Hello\nWorld (D)</p> Signup and view all the answers

Which command displays the users currently logged into the system?

<p>users (B)</p> Signup and view all the answers

What time zone does EET stand for?

<p>Eastern European Time (C)</p> Signup and view all the answers

Which one of the following commands will output the current hour, minutes, and seconds?

<p>date +%H:%M:%S (A)</p> Signup and view all the answers

Flashcards

What is the tty command?

Displays your current terminal name.

What is the who command?

Shows who is logged on to the system.

What is the users command?

Displays currently logged in users.

What is the date command?

Shows current date and time.

Signup and view all the flashcards

What is the pwd command?

Print the current working directory.

Signup and view all the flashcards

What is the ls command?

Lists directory contents.

Signup and view all the flashcards

What is the ls -a command?

Lists all directory contents including hidden files.

Signup and view all the flashcards

What is the ls -l command?

Lists detailed information about files and directories.

Signup and view all the flashcards

What is the cd command?

Changes the current directory.

Signup and view all the flashcards

What is the mkdir command?

Creates a new directory.

Signup and view all the flashcards

What is the rmdir command?

Removes an empty directory.

Signup and view all the flashcards

What is the touch command?

Creates a new file.

Signup and view all the flashcards

What is the cat command?

Displays the content of a file.

Signup and view all the flashcards

What does echo 'text' >> file do?

Adds text to the end of a file.

Signup and view all the flashcards

What does echo 'text' > file do?

Overwrites the contents of a file with the given text.

Signup and view all the flashcards

What does the cal command do?

Displays a calendar for a specific month and year.

Signup and view all the flashcards

Study Notes

Basic Terminal Commands and Information

  • tty displays the terminal name. In this case, it shows /dev/pts/0.
  • who displays who is logged in.
  • users displays the users currently logged in.
  • w displays information about the users logged in, including uptime, user, tty, from, login time, idle time, JCPU, PCPU and what the user is doing.
  • date displays the current date and time.
  • date '+%y' displays the current year in two-digit format. Result shows 25.
  • date '+%Y' displays the current year in four-digit format. Result shows 2025.
  • cal displays the calendar of the current month.
  • cal 4 24 displays the calendar for April 2024.
  • date +%H:%M:%S displays the current time in HH:MM:SS format, with a result of 01:25:58.
  • pwd displays the present working directory, which is /home/dina.
  • ls lists the files and directories in the current directory.
  • ls -a lists all files and directories, including hidden ones (those starting with a .). shows an error due to a space after ls.
  • Navigating to the Desktop directory using cd Desktop.

File and Directory Permissions

  • The output of ls -l shows detailed information about files and directories, including permissions, number of links, owner, group, size, and modification date.
  • total 48 indicates the total disk usage of the directory.
  • Permissions are displayed as a string (e.g., drwxr-xr-x).
  • The initial d indicates a directory; - indicates a file.
  • The letters that follow represent permissions: r for read, w for write, and x for execute (or search, for directories).
  • The permissions are shown for the owner, group, and others, in that order.

File and Directory Manipulations

  • ls gr* lists files starting with "gr".
  • ls te*.txt lists files starting with "te" and ending with ".txt".
  • Create directories using mkdir.
  • Remove empty directories using rmdir.
  • Remove files using rm.

Redirection and Piping

  • echo "Hello">test12.txt overwrites the file test12.txt with the word "Hello".
  • echo "World">>test12.txt appends the word "World" to the end of the file test12.txt.
  • cat test12.txt displays the contents of the file test12.txt.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser