1.
Quais comandos podem ser usados para paginar a saída de um resultado emitido por um determinado comando ? (Selecione 2 respostas).
Correct Answer(s)
B. more
C. less
Explanation
The commands "more" and "less" can be used to paginate the output of a command. These commands allow the user to view the output one page at a time, making it easier to read and navigate through large amounts of information. "More" displays one page of output at a time and waits for the user to press the Enter key to view the next page, while "less" provides similar functionality but also allows for backward scrolling and searching within the output.
2.
Qual comando substitui espaços de tabulação (TABs) por espaços simples, mantendo a mesma distância aparente?
Correct Answer(s)
expand
Explanation
The command "expand" can be used to replace tab spaces with single spaces while maintaining the same apparent distance.
3.
Qual comando expand com opção irá substituir apenas as ocorrências em inicio de linha ?
Correct Answer(s)
expand -i
Explanation
The command "expand -i" with the "-i" option will replace only the occurrences at the beginning of each line.
4.
O comando expand -t N irá especificar o valor a ser substituído para o tamanho da tabulação.
Correct Answer
A. Verdadeiro
Explanation
The given statement is true. The command "expand -t N" is used to specify the value to be substituted for the tab size. By using this command, the tab characters in a file can be replaced with spaces. The "N" in the command represents the desired tab size.
5.
Qual comando pode ser utilizado para formatar arquivos de texto ?
Correct Answer
fmt
Explanation
O comando "fmt" pode ser utilizado para formatar arquivos de texto.
6.
Suponha que possuo um arquivo chamado "texto.txt" que possui o total de 100 linhas. Qual comando poderia utilizar para definir a formatação deste arquivo para mostrar na saída padrão cada linha com largura de valor igual a 10 ?
Correct Answer
fmt -w 10 texto.txt
Explanation
The command "fmt -w 10 texto.txt" can be used to set the formatting of the file "texto.txt" so that each line is displayed with a width of 10 characters on the standard output.
7.
Qual comando pode ser utilizado para mostrar as linhas iniciais de um arquivo, onde por padrão as 10 primeiras linhas serão mostradas.
Correct Answer
head
Explanation
The "head" command is used to display the first few lines of a file. By default, it shows the first 10 lines of the file.
8.
Supondo que gostaria de listar os 30 primeiros caracteres do arquivo /etc/passwd utilizando o comando head. Qual seria o comando completo para realizar tal tarefa ?
Correct Answer
head -c 30 /etc/passwd
Explanation
The given command "head -c 30 /etc/passwd" is the correct answer. The command "head" is used to display the first few lines of a file, and the option "-c" is used to specify the number of characters to display. Therefore, "head -c 30 /etc/passwd" will display the first 30 characters of the file /etc/passwd.
9.
Supondo que gostaria de listar as 5 primeiras linhas do arquivo /etc/passwd utilizando o comando head. Qual seria o comando completo para realizar tal tarefa ?
Correct Answer
head -n 5 /etc/passwd
Explanation
The given command "head -n 5 /etc/passwd" is the correct command to list the first 5 lines of the /etc/passwd file using the head command. The "head" command is used to display the beginning of a file, and the "-n" option specifies the number of lines to be displayed. So, in this case, it will display the first 5 lines of the /etc/passwd file.
10.
Qual comando concatena registros de dois arquivos de texto baseado em índices comuns ? O comando funciona como um tipo de banco de dados primitivo, permitindo a montagem de novos arquivos de registros a partir de registros existentes em diferentes arquivos.
Correct Answer
join
Explanation
The command "join" is used to concatenate records from two text files based on common indices. It acts as a primitive database, allowing the assembly of new record files from existing records in different files.
11.
Qual comando pode ser utilizado para unir as linhas de dois arquivos utilizando um caractere delimitador na saída do resultado obtido?
Correct Answer
paste
Explanation
The "paste" command can be used to merge the lines of two files together using a delimiter character in the output result.
12.
Supondo que você possui 2 arquivos de texto (arq1.txt e arq2.txt), onde o arq1.txt possui os seguintes nomes para cada linha do arquivo: fulano, beltrano e cicrano, e no arq2.txt os seguintes domínios por linha no arquivo; hotmail.com, gmail.com e yahoo.com. Qual o comando completo que irá unir as linhas dos dois arquivos em uma única linha na saída padrão separadas pelo caractre "@" ?
Correct Answer
B. paste -d "@" arq1.txt arq2.txt
Explanation
The correct answer is "paste -d "@" arq1.txt arq2.txt". The "paste" command is used to merge lines from two files side by side. The "-d" option is used to specify the delimiter character to separate the merged lines, which in this case is "@" as stated in the question. Therefore, the command "paste -d "@" arq1.txt arq2.txt" will join the lines from arq1.txt and arq2.txt into a single line with "@" as the delimiter.
13.
Qual parâmetro do comando paste irá unir as linhas de um arquivo em uma só linha ?
Correct Answer
C. paste -s
Explanation
The parameter "paste -s" in the command "paste" will join the lines of a file into a single line.
14.
Supondo que você não possua nenhum editor de texto instalado no seu sistema, mesmo os editores padrões. Qual comando (Completo) pode ser utilizado para criar uma arquivo chamado; myfile.txt e logo em seguida inserir um texto qualquer neste arquivo ?
Correct Answer
cat > myfile.txt
Explanation
cat > arquivo.txt e logo após a digitar o texto. finalize com Crtl+d
15.
Supondo que você possui dois arquivos, eles são: arq1.txt e arq2.txt. Como você faria para imprimir o conteúdo do arq1.txt ao final do conteúdo do arq2.txt sem sobrescrever o conteúdo do arq2.txt ? (Utilze o comando cat).
Correct Answer
cat arq1.txt >> arq2.txt
Explanation
The command "cat arq1.txt >> arq2.txt" is used to append the content of arq1.txt to the end of arq2.txt without overwriting the existing content in arq2.txt. The ">>" operator is used for appending, while the "cat" command is used to concatenate and display the contents of a file.
16.
O comando fmt, por padrão ajusta o texto de um arquivo com 75 caracteres por linha.
Correct Answer
A. Verdadeiro
Explanation
The given statement is true. The fmt command, by default, adjusts the text of a file to have 75 characters per line. This means that if a line exceeds 75 characters, the fmt command will automatically break it into multiple lines to maintain the desired line length.
17.
Utilizando o comando od. Como faria para exibir o conteúdo do arquivo myfile.txt no formato octal ?
Correct Answer
od -t o myfile.txt
Explanation
The command "od -t o myfile.txt" is used to display the content of the file "myfile.txt" in octal format. The "od" command is a tool used to display file contents in different formats, and the "-t o" option specifies that the output should be in octal format. By running this command, the content of the "myfile.txt" file will be displayed in octal format.
18.
Utilizando o comando od. Como faria para exibir o conteúdo do arquivo myfile.txt no formato ASCII ?
Correct Answer
od -t c myfile.txt
Explanation
The command "od -t c myfile.txt" is used to display the content of the file "myfile.txt" in ASCII format. The "od" command is used to dump files in octal and other formats, and the "-t c" option specifies that the output should be in ASCII characters.
19.
Utilizando o comando od. Como faria para exibir o conteúdo do arquivo myfile.txt no formato Hexadecimal ?
Correct Answer
od -t x myfile.txt
Explanation
The command "od -t x myfile.txt" is used to display the contents of the file "myfile.txt" in hexadecimal format. The "od" command is used to dump files in various formats, and the "-t x" option specifies that the output should be in hexadecimal format.
20.
Supondo que você possui um arquivo chamado myfile.txt, onde seu tamanho é de 1024 bytes. Como você faria para dividir este arquivo em parte menores de 256 bytes cada ?
Correct Answer
C. split -b 256 myfile.txt split-file.txt-
Explanation
To divide the myfile.txt file into smaller parts of 256 bytes each, the correct command is "split -b 256 myfile.txt split-file.txt-". This command uses the "split" utility, with the "-b" option to specify the size of each part, followed by the name of the input file (myfile.txt), and the prefix for the output files (split-file.txt-). This command will create multiple output files, each containing 256 bytes of data from the original file.
21.
Supondo que você possui um arquivo chamado myfile.txt, onde tal arquivo possui 4000 linhas. Como você faria para dividir o arquivo myfile.txt em 10 arquivos utilizando o comando split ?
Correct Answer
C. split -l 400 myfile.txt split-myfile-
Explanation
The correct answer is "split -l 400 myfile.txt split-myfile-". This command will divide the file "myfile.txt" into 10 separate files, each containing 400 lines. The output files will be named "split-myfile-aa", "split-myfile-ab", "split-myfile-ac", and so on.
22.
Quais dos comandos abaixo irá ocultar a ocorrência do caractere "s" no arquivo /etc/passwd ? (Selecione 2 respostas).
Correct Answer(s)
A. cat /etc/passwd | tr -d s
B. tr -d s < /etc/passwd
Explanation
The first command "cat /etc/passwd | tr -d s" will display the contents of the /etc/passwd file and then remove all occurrences of the letter "s". The second command "tr -d s < /etc/passwd" will read the contents of the /etc/passwd file and remove all occurrences of the letter "s". Therefore, both of these commands will hide the occurrence of the letter "s" in the /etc/passwd file.
23.
Qual comando é utilizado para criar um novo arquivo de texto vazio?
Correct Answer(s)
touch
Explanation
The command "touch" is used to create a new empty text file.
24.
Qual o comando completo, utilizando o touch, irá alterar a data e hora da ultima modificação do arquivo touch.txt para 24/12/2016 às 23:59 ?
Correct Answer(s)
touch -m -t 201612242359 touch.txt
Explanation
The correct answer is "touch -m -t 201612242359 touch.txt". This command uses the touch command with the options -m (modify the timestamp) and -t (specify the timestamp). The timestamp given is 201612242359, which represents the date and time 24/12/2016 at 23:59. The command is applied to the file touch.txt, changing its last modification date and time to the specified value.
25.
Ao realizar o comando cat /etc/passwd | _____ [:lower:] [:upper:], todo o conteúdo do arquivo será mostrado em caixa alta.
Correct Answer
D. tr
Explanation
By using the "tr" command with the options [:lower:] [:upper:], all the content of the "/etc/passwd" file will be displayed in uppercase. The "tr" command is used for translating or deleting characters, and in this case, it is translating lowercase letters to uppercase letters.
26.
Para modificar a palavra “teste” pela palavra “testes” em um arquivo denominado arq1, podemos usar o comando _______ 's/teste/testes/g' arq1
Correct Answer
A. sed
Explanation
The correct answer is "sed". The sed command is used for text manipulation and stands for "stream editor". In this case, the command 's/teste/testes/g' is used to substitute the word "teste" with "testes" in the file named "arq1". The 's' indicates a substitution, the 'g' stands for global (replacing all occurrences), and the forward slashes are used to delimit the search and replacement strings.
27.
Para modificar a palavra “teste” pela palavra “testes” em um arquivo denominado arq1, podemos usar o comando _______ 's/teste/testes/g' arq1
Correct Answer
A. sed
Explanation
The correct answer is "sed". Sed is a command-line utility for editing text files. In this context, the sed command is being used with the 's/teste/testes/g' pattern, which means to substitute all occurrences of the word "teste" with "testes" in the file named "arq1".
28.
Ao executar o comando ls > ls.txt
Correct Answer(s)
A. Caso não exista, o arquivo ls.txt será criado.
B. O conteúdo anterior de ls.txt será apagado.
Explanation
Ao executar o comando "ls > ls.txt", o que acontece é que o comando "ls" é executado e o resultado é redirecionado para o arquivo "ls.txt". Se o arquivo "ls.txt" não existir, ele será criado. Se o arquivo já existir, o conteúdo anterior será apagado e substituído pelo resultado do comando "ls". Portanto, a resposta correta é que, caso não exista, o arquivo "ls.txt" será criado e o conteúdo anterior será apagado.
29.
Ao executar o comando: sed -i 's/$/;/' teste2.txt
Correct Answer
C. Será adicionado um ';' no final de cada linha, dentro do arquivo teste2.txt
Explanation
The given command "sed -i 's/$/;/' teste2.txt" uses the sed command to edit the file "teste2.txt" in-place (-i option). The 's/$/;/' part of the command is a sed substitution expression, where it searches for the end of each line ($) and replaces it with a semicolon (;). Therefore, the command will add a semicolon at the end of each line within the file "teste2.txt".
30.
Você deseja definir as suas opções de shell de forma que a saída de um redirecionamento não vai sobrescrever um arquivo existente. Digite o comando incluindo switches.
Correct Answer
set -o noclobber
Explanation
The command "set -o noclobber" is used to prevent the output of a redirection from overwriting an existing file. When this option is enabled, if a redirection tries to create a file that already exists, it will fail and an error message will be displayed.
31.
Qual é o nome e o caminho completo do arquivo que contém as variáveis de ambiente e programas de inicialização?
Correct Answer
/etc/profile
Explanation
The correct answer is /etc/profile. This file contains the environment variables and initialization programs. It is located in the /etc directory.
32.
Qual dos comandos abaixo irá retornar o status de saída do comando anterior (1 ou 0)?
Correct Answer
A. echo $?
Explanation
The correct answer is "echo $?" because the "$?" is a special variable in Unix-like operating systems that holds the exit status of the previously executed command. By using the "echo" command with "$?", it will display the exit status (either 1 or 0) of the previous command.
33.
Que comando irá mostrar-lhe os valores definidos pelo arquivo /etc/profile para todo o sistema ?
Correct Answer
env
Explanation
The "env" command will display the values set by the /etc/profile file for the entire system. This command is used to print the current environment variables. By running "env", you can see the environment variables that have been set, including those defined in the /etc/profile file.
34.
Que comando irá mostrar-lhe os valores definidos pelo arquivo /etc/bashrc para todo o sistema ?
Correct Answer
set
Explanation
The "set" command will display the values defined by the /etc/bashrc file for the entire system.
35.
O que faz o seguinte comando? cat \$TEST
Correct Answer
B. Exibe o conteúdo do arquivo chamado $TEST se ele existir.
Explanation
This command "cat $TEST" is used to display the contents of the file named $TEST, if it exists. The "cat" command is commonly used in Unix-like operating systems to concatenate and display the contents of files. In this case, the variable $TEST is being used to specify the file name, and if the file exists, its contents will be displayed.
36.
Qual é o resultado do seguinte comando? cat 'echo" $testking
Correct Answer
A. Um erro de sintaxe.
Explanation
The given command is cat 'echo" $testking. This command contains a syntax error because it is using both single quotes and double quotes in an incorrect way. The correct way to use quotes in this command would be either to use double quotes around the entire command or to escape the inner double quotes with a backslash. Since the command is incorrect, it will result in a syntax error.
37.
Qual dos comandos abaixo irá mostrar-lhe apenas as 10 linhas intermediárias de um arquivo de texto com 30 linhas chamado textfile?
Correct Answer
B. head -n 20 textfile | tail
Explanation
The correct answer is "head -n 20 textfile | tail". This command uses the "head" command to display the first 20 lines of the textfile and then pipes the output to the "tail" command, which displays the last 10 lines of the output. Therefore, it will show only the 10 intermediate lines of the textfile.
38.
Qual comando irá exibir em ordem inversa o conteúdo do arquivo file, além de numerar todas as linhas de tal arquivo ?
Correct Answer
B. cat file | tac | nl
Explanation
The correct answer is "cat file | tac | nl". The command "tac" is used to reverse the order of lines in a file, and the command "nl" is used to add line numbers to the output. By piping the output of "cat file" into "tac" and then into "nl", the content of the file will be displayed in reverse order with line numbers.
39.
Depois de executar a seguinte linha de comando; echo \"test king\ " | cat > myout.txt. Qual será o conteúdo do arquivo myout.txt ?
Correct Answer
B. "test king"
Explanation
The command "echo "test king" | cat > myout.txt" will redirect the output of the "echo" command, which is "test king", to the file "myout.txt". Therefore, the content of the file "myout.txt" will be "test king".
40.
Qual das opções abaixo irá contar o número total de linhas com a palavra "testking" em /var/log/maillog ?
Correct Answer
D. cat /var/log/maillog | grep 'testking' | wc -l
Explanation
The correct answer is "cat /var/log/maillog | grep 'testking' | wc -l". This command will display the contents of the maillog file, filter out the lines that contain the word 'testking' using the grep command, and then count the number of lines using the wc command with the -l option. This will give the total number of lines with the word 'testking' in the maillog file.
41.
Qual dos seguintes comandos sed irá substituir todas as ocorrências da string "foo" para "foobar" sem que o arquivo file1.txt seja alterado?
Correct Answer
A. sed 's/foo/foobar/g' file1.txt
Explanation
The correct answer is "sed 's/foo/foobar/g' file1.txt". This command uses the sed utility to perform a search and replace operation in the file file1.txt. It searches for all occurrences of the string "foo" and replaces them with "foobar". The "g" flag is used to indicate that the replacement should be done globally, meaning all occurrences of "foo" will be replaced. This command does not alter the original file file1.txt.
42.
Qual comando irá imprimir uma lista de nomes de usuário (primeira coluna) e seu user id (uid, terceira coluna) correspondente no arquivo /etc/passwd ?
Correct Answer
C. cut -d: -f 1,3 /etc/passwd
Explanation
The correct answer is "cut -d: -f 1,3 /etc/passwd". This command uses the "cut" utility to extract specific columns from the "/etc/passwd" file. The "-d:" option specifies that the fields in the file are separated by colons, and the "-f 1,3" option indicates that we want to extract the first and third fields (username and uid). This command will print a list of usernames and their corresponding user ids.
43.
Você emitiu o comando "ls | grep .a[^b]a.". Quais arquivos são retornados pelo comando? (Escolha todas que se aplicam).
Correct Answer(s)
A. ratas
B. jacaw
C. saran
Explanation
The command "ls | grep .a[^b]a." searches for files that have a letter followed by "a" and another letter that is not "b" and then followed by "a" and any character. Among the given options, the files "ratas", "jacaw", and "saran" meet this criteria and will be returned by the command.
44.
Você precisa exibir todos os arquivos no diretório atual que começam com um "a" e final com um "v", independentemente do seu comprimento, ou a utilização de delimitadores. (Escolha a melhor resposta).
Correct Answer
A. ls a*v
Explanation
The correct answer is "ls a*v" because it uses the wildcard character "*" to represent any number of characters between "a" and "v". This will match any file in the current directory that starts with "a" and ends with "v", regardless of the length or the use of delimiters.
45.
Qual comando irá remover todos os arquivos nomeados de "core" nos diretórios pessoais dos usuários (/home), que possuam mais de 7 dias de idade, desde sua última modificação? (Digite o comando mais simples para fazer isso).
Correct Answer
find /home -mtime +7 -name core -exec rm {} \;
find /home -name core -mtime +7 -exec rm {} \;
find /home -name 'core' -mtime +7 -exec rm {} \;
find /home -mtime +7 -name 'core' -exec rm {} \;
find /home -mtime +7 -name "core" -exec rm {} \;
find /home -name "core" -mtime +7 -exec rm {} \;
Explanation
The correct answer is "find /home -mtime +7 -name core -exec rm {} \;". This command uses the "find" command to search for files named "core" in the /home directory that are older than 7 days (-mtime +7). It then executes the "rm" command to remove those files.
46.
O que o comando seguinte irá fazer ? cmd > file.out 2>&1
Correct Answer
B. Envia a stdout e stderr de cmd para file.out
Explanation
The given command "cmd > file.out 2>&1" redirects both the standard output (stdout) and the standard error (stderr) of the command "cmd" to the file "file.out". This means that any output or error messages generated by "cmd" will be written to the "file.out" file.
47.
Você criou uma longa carta e depois percebeu que usou o nome "bob" muitas vezes, mas você esqueceu de capitalizá-lo em muitos casos. Qual comando iria substituir "bob" por "Bob" em todas as instâncias e gerar uma nova carta para impressão?
Correct Answer
C. sed 's/bob/Bob/g' carta.txt > nova_carta.txt
Explanation
The correct answer is "sed 's/bob/Bob/g' carta.txt > nova_carta.txt". This is because the sed command is used for text manipulation and the 's' option stands for substitute. The pattern 'bob' is being replaced with 'Bob' using the 'g' flag, which means globally (i.e., all instances of 'bob' in the file will be replaced). The output of the command is redirected to a new file called "nova_carta.txt".
48.
Um usuário precisa procurar um arquivo para as linhas que contenham o caractere asterisco (*). Qual dos comandos abaixo irá conseguir isso ? (Escolha todas que se aplicam).
Correct Answer(s)
A. grep \* textfile
B. grep '*' textfile
D. grep "*" textfile
Explanation
The correct answers are "grep \* textfile", "grep '*' textfile", and "grep "*" textfile". These commands will search for lines in the "textfile" that contain the asterisk character (*). The backslash (\) is used to escape the special meaning of the asterisk character in regular expressions. The single quotes ('') and double quotes ("") are used to treat the asterisk character as a literal character. The command "grep \ textfile" will search for lines that contain a space, not an asterisk. The command "grep "'*'" textfile" will search for lines that contain the literal string "*".
49.
Qual dos comandos abaixo utiliza a variável de ambiente PATH para buscar um programa fornecido como argumento ?
Correct Answer
C. which
Explanation
The command "which" utilizes the PATH environment variable to search for a program provided as an argument. It helps in locating the executable file associated with a given command by searching through the directories listed in the PATH variable. This command is commonly used in Unix-like operating systems to determine the location of a command that will be executed when it is typed in the terminal.
50.
O comando; "find -type -l" irá procurar quais tipos de arquivos ?
Correct Answer
A. Links simbólicos
Explanation
The command "find -type -l" is used to search for symbolic links. The "-type -l" option specifies that only symbolic links should be searched for.