Skip to content

Latest commit

 

History

History
309 lines (189 loc) · 6.88 KB

File metadata and controls

309 lines (189 loc) · 6.88 KB

1. (B) Extract the "challenges.tar.gz" archive.

O comando utilizado para descompactar o arquivo solicitado foi:

tar -vzxf challenges.tar.gz

2. (B) - Change your working directory to the "challenges" directory that was created when you extracted "challenges.tar.gz".

O comando utilizado para mudar para o diretório solicitado foi:

cd challenges

3. (B) List the contents of the "challenges" directory.

O comando utilizado para listar o conteúdo do diretório solicitado (considerando que a pessoa já está no diretório correto) foi:

ls

4. (B) Create a new directory named "foo".

O comando utilizado para criar um novo diretório com o nome solicitado foi:

mkdir foo

5. (I) Create a new directory named "foo/bar/1/2/3".

O comando utilizado para criar a estrutura de diretórios foi:

mkdir -p foo/bar/1/2/3

6. (B) Remove the directory "foo" and all of its contents.

O comando utilizado para excluir o diretório indicado e seu conteúdo foi:

rm -r foo

7. (B) Print the text "Hello World".

Para imprimir o texto no terminal, utilizou-se o comando:

echo "hello world"

8. (B) Create a file named "hello.txt" that contains the text "Hello World".

O comando utilizado para criar o arquivo com o conteúdo dentro foi:

echo "Hello World" > hello.txt

9. (B) Create an empty file named "empty.txt"

O comando utilizado para criar o arquivo vazio foi:

touch empty.txt

10. (B) Remove the file "empty.txt"

O comando utilizado para apagar o arquivo vazio foi:

rm empty.txt

11. (I) Find a second way to solve challenge 9.

Outra forma de criar um arquivo vazio é pelo comando:

> empty.txt

12. (I) Find a third way to solve challenge 9.

Mais uma forma de criar um arquivo vazio é pelo comando:

truncate -s 0 empty.txt

13. (B) Copy "hello.txt" and name the copy "goodbye.txt".

O comando utilizado para copiar um arquivo e renomeá-lo foi:

cp hello.txt goodbye.txt

_14. (B) Rename "goodby.txt" to "hello_copy.txt".

O comando utilizado para renomear o arquivo foi:

mv goodby.txt hello_copy.txt

15. (I) Prove that the contents of "hello.txt" and "hello_copy.txt" are identical.

O comando utilizado para exibir o conteúdo dos dois arquivos, mostrando assim que o conteúdo é igual, foi:

cat hello.txt hello_copy.txt

16. (B) Concatenate the contents of "hello.txt" and "hello_copy.txt" and store the result in a file named "2_hellos.txt".

O comando utilizado para concatenar o conteúdo dos dois arquivos e colocar em um terceiro criado foi:

cat hello.txt hello_copy.txt > 2_hellos.txt

17. (B) Get the full path of your present working directory ("challenges").

O comando utilizado para exibir o caminho da pasta atual foi:

pwd

18. (B) List the contents of the "challenges" directory (like challenge 3), but show the permissions for each filxse.

O comando utilizado para listar o conteúdo do diretório solicitado e mostrar as permissões (considerando que a pessoa já está no diretório correto) foi:

ls -l

19. (B) Append some text to the end of "restricted.txt". It's OK to do this in 2 steps.

Para inserir um texto no final do arquivo solicitado, foi necessário usar o comando abaixo juntamente com o sudo para permitir a ação. "-c" é utilizado para indicar ao shell que o próximo argumento é um comando a ser executado.

sudo sh -c 'echo "Texto de teste" >> restricted.txt'

20. (B) Run the "hello_executable" program.

Para rodar o programa, utilizou-se o comando abaixo:

./hello_executable

21. (B) Run the "challenge_20" program. It's OK to do this in 2 steps.

Para tornar o arquivo executável e rodá-lo, foi utilizado o comando:

chmod +x challenge_20 && ./challenge_20

22. (B) Compile and run "compile_me.c". It's OK to do this in 2 steps.

Para compilar o programa e rodá-lo, foi utilizado o compilador C padrão junto ao comando para executá-lo:

gcc -o compile_me compile_me.c && ./compile_me

23. (A) Run the "redirect" program and collect all of its output in a file named "output.txt".

Para rodar o programa indicado, direcionar sua saída para o arquivo "output.txt" e então o abrir, foi utilizado o comando:

./redirect > output.txt && xdg-open output.txt

24. (B) Get the current date and time.

O comando utilizado para visualizar data e hora atual foi:

date

25. (B) Show all of the running processes on your computer.

O comando utilizado para mostrar os processos em execução (de todos os usuários) foi:

ps aux

26. (B) Show the number of processors/cores in your computer.

O comando utilizado para mostrar o número de processadores/cores foi:

nproc

27. (B) Find out what version of the Linux kernel is currently running.

O comando utilizado para mostrar a versão do kernel do Linux foi:

uname -r

28. (B) Find the file in the "bunch_of_files/" directory that contains the string: "You found the needle in the haystack!"

O comando utilizado para encontrar a String indicada, foi:

grep -l "You found the needle in the haystack!" *

29. (B) Print the first 25 lines of people.csv.

O comando utilizado para listar as primeiras 25 linhas do arquivo indicado foi

head -n 25 people.csv

30. (B) Print the last 25 lines of people.csv.

O comando utilizado para listar as últimas 25 linhas do arquivo indicado foi:

tail -n 25 people.csv

31. (I) Display just the differences between greeting1.txt and greeting2.txt

O comando utilizado para mostrar apenas as diferenças entre os dois arquivos indicados foi:

diff greeting1.txt greeting2.txt

32. (I) Print "Hello", then wait 5 seconds, then print "world!".

O comando utilizado para imprimir a palavra "Hello", aguardar 5 segundos e então imprimir "world!" foi:

echo "Hello" && sleep 5s && echo "world!"

33. (I) Create a 1MB file full of zeros.

O comando utilizado para criar um arquivo cheio de zeros com 1MB foi:

truncate -s 1M arquivo-zeros.txt

34. (I) Create a 2MB file full of random data.

O comando utilizado para criar um arquivo cheio de dados aleatórios com 2MB foi:

head -c 2M /dev/urandom > arquivo_aleatorios.txt

35. (I) Count the number of lines in README.txt.

O comando utilizado para contar o número de linhas do arquivo indicado foi:

wc -l README.txt

36. (B) Display the contents of README.txt in reverse (last line first).

O comando utilizado para exibir o conteúdo do arquivo indicado a partir do final foi:

tac README.txt

37. (I) Display all of the last names in people.csv.

O comando utilizado para exibir a coluna que contém os sobrenomes, que estão na coluna 2, foi:

awk -F ',' '{print $2}' people.csv