Commands Flashcards

1
Q

cd

A

The “Change Directory” command enables you to navigate to another directory. As the command suggests, it enables the user to change / jump to a directory.
Example: cd Downloads
Example: cd /etc/
Example: cd .. (Directory up!)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

man

A

The man command shows the users the “manual” of the command. In some situation you might need to get more information about the command you are using. The man command shows you this information about the command. Example: man cp
This will open up the “cp” manual document for us in the shell. The manual shows us the parameters available for the commands.
note: To close the manual simply press “Q”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ls

A

The ls command is used to list the files/directories within a directory.
Example: ls
It shows us the directories available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

cp

A

The cp command is available for us to “Copy” things. This might be usefull for duplicating files f.e.
Example: cp file file2
note: file is on this case the file the user wants to be copied… file2 is the name of the copied file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

mv

A

The mv command is used for “Move” operations. The mv commands enables the users to move a file/directory to a specified location.
Example: mv /home/bas/Desktop/bla /home/bas/Desktop/fiets

note: the first part of the command is the file that has to be moved. The second part (after the whitespace) is the target directory. Make sure you type in the full path using this command!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

mkdir

A

This command is used to “make” directories, NOT Files.. (thit is possible with another command which i will bring up later in this tutorial)
Example: mkdir testdirectory
note: The name of the directory is case sensitive which means that Testdirectory is a complete different directory as testdirectory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

rmdir

A

When you are able to make directories, you also want to know how to remove them. Removing directories is done by the rmdir command and belongs to the absolute basic commands in shell bashing.
Example: rmdir fiets
note: When the directory is not empty the command will prompt an error message:
rmdir: failed to remove `fiets’: Directory not empty
So make sure it’s completely empty before removing it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

touch

A

Now we know how to make directories and deleting them, i now want to use the touch command. The touch command is used to make files.
Example: touch vogel
This will create the file vogel for us in the directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

rm

A

The rm command stand for remove. The rm command is used in order the delete files instead of directories.
Example: rm vogel
note: To remove files you must have the right permission bits set on the specific file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

tar

A

Sometimes you have to archive files. Archiving files is a way to pack a set of files to one single file. The operation is done by the tar command.
Example: tar -cvf test.tar test (Creating a tar file from directory or file test)
Example: tar -xvf test.tar myexctractfolder (Extracts the particular tar file in the current working directory)
In the example i used parameters. These parameters are telling the tar command how to behave and how to execute. After the parameters i entered the name of the file which is test.tar. The second part is the source directory/file of the tar file. In this situation a directory called test.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

pwd

A

Sometimes you really wonder where you are in the system. PWD is the solution for that problem.
PWD stands for Path Working Directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ifconfig

A

ifconfig is a command showing you information about the ethernet adapters on your system. It contains very usefull information like gateway, ip, and packet statistics. For the average user this command is rarely used, but i think it’s worth knowing it.
Example: ifconfig
note: To gain information about the wireless adapters on your system type iwconfig.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

locate

A

Locate is an extremely fast seaching command. It shows the directories or files each on a new line.
Example: locate syslog
Example: locate syslog | more (Piping structure used to invert the data from locate to the more command)
note: Some keywords returns enormous ammounts of hits. Use MORE to (see example) clear things up a bit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

chmod

A

To change permissions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

cat [filename]

A

Display file’s contents to the standard output device

usually your monitor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

chown (options) filename

A

Change who owns a file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

clear

A

Clear a command line screen/window for a fresh start

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

date

A

display or set the system date and time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

df (options)

A

display used and available disk space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

du (options)

A

show how much space each file takes up

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

file (options) filename

A

determine what type of data is within a file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

find {paththname} {expression}

A

search for files matching a provided pattern
find files using filename (case in-sensitive find):
# find -iname “MyCProgram.c”
find all empty file in home directory
# find ~ -empty

23
Q

grep [options] pattern [filesname]

A

search files or output for a particular pattern

24
Q

kill [options] pid

A

stop a process. If the process refuses to stop, use kill -0 pid

25
Q

less [options] [filename]

A

view the contents of a file one page at a time

26
Q

ln [options] source [destination]

A

create a shortcut

27
Q

locate filename

A

search a copy of your filesystem for the specified filename

28
Q

lpr [options]

A

send a print job

29
Q

passwd

A

change the password or allow (for the system administrator to)

30
Q

ps [options]

A

display a snapshot of the currently running processes

31
Q

pwd

A

display the pathname of the current directory

32
Q

ssh [options] user@machine

A

remotely log in to another linux machine, over the network

33
Q

su

A

switch to another user account

su - username

34
Q

tail

A

display the last n lines of a file (the default is 10)

35
Q

tar [options] filename

A

store and extract files from a tarfile (.tar) or tarball (.tar.gz or .tgz).

36
Q

top

A

displays the resources being used on your system. Press q to exit

37
Q

who

A

display who is logged on

38
Q

wget

A

download files from Internet

39
Q

rpm

A

install software,
rpm -ivh to install
rpm -uvh to upgrade
rpm -ev to uninstall

40
Q

yum

A

install software
yum install httpd to install
yum update httpd to upgrade
yum remove httpd to uninstall

41
Q

whereis

A

to fin out where a specific linux command exists, ex:
whereis ls
ls: /bin/ls

42
Q

uname

A

displays important information about the system such as kernel name, host name, release number, processor type, etc.
uname -a

43
Q

mount

A

to mount a filesystem, first create a directory and mount it as show below:
mk /u10
mount /dev/sdb1 /u01.
You can also add this to fstab for automatic mounting, ie. anytime the system is restarted, the file system is mounted,
/dev/sdb1 /u01 ext2 defaults 0 2

44
Q

service

A
used to run the system V init scripts. Instead of calling the scripts located in the directory with their full path, you can use the service command
# service ssh status
# service ssh restart
# service --status -all
45
Q

cron

A

process that executes commands at specific dates and times

46
Q

crontab

A

commands that need to be executed repeatedly (ex: hourly, daily, weekly), use the crontab command, which create a crontab file containing commands and instructions for the cron daemon to execute

47
Q

ftp

A

ftp and sftp is used to connect to a remote server

48
Q

shutdown

A

shutdown -h now (power off immediately)
shutdown -h +10 (power off in 10 minutes
shutdown -r now (reboot)

49
Q

unzip

A

to extract a .zip compressed file

50
Q

bzip2

A

to create a .bz2 compress file:
bzipe2 test.txt
to uncompress a .bz2 file:
bzip2 -d test.txt.bz2

51
Q

gzip

A

to create a .gz compressed file:
gzip test.txt
to uncompress a .gz file
gzip -d test.txt.gz

52
Q

sort

A
sort a file in ascending order
sort names.txt
sort a file in descending order
sort -r names.txt
sort passd file by 3rd field
sort -t: -k 3n /etc/passwd | more
53
Q

diff

A
ignore white space while comparing:
# diff -w name_list.txt name_list_new.txt
54
Q

vim

A
go to the 143rd line of a file:
$ vim +143 filename.txt
go to the first match of the specified
$ vim +/search-term filename.txt
open the file in read only mode
$ vim -R /etc/passwd