Leni Andriani - 3.1.2.6 Lab - Working With Text Files in The CLI
Leni Andriani - 3.1.2.6 Lab - Working With Text Files in The CLI
Leni Andriani - 3.1.2.6 Lab - Working With Text Files in The CLI
Introduction
In this lab, you will get familiar with Linux commandline text editors and configuration files.
Required Resources
CyberOps Workstation Virtual Machine
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 1 of 10
Lab – Working with Text Files in the CLI
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 2 of 10
Lab – Working with Text Files in the CLI
What character doesnano use to represent that a line continues beyond the boundaries of the screen?
Pada home
c. As shown on the bottom shortcut lines, CTRL+Xcan be used to exit nano. nano will ask if you want to
save the file before exiting (‘Y’ for Yes,or N for ‘No’). If ‘Y’ is chosen, you will be prompted to press enter
to accept the given file name, or change the file name, or provide a file name if it is a new unnamed
document.
d. To control nano, you can use CTRL, ALT, ESCAPE or the META keys. The META key is the key on the
keyboard with a Windows or Mac logo, depending on your keyboard configuration.
e. Navigation in nano is very user friendly. Use the arrows to move around the files. Page Up and Page
Down can also be used to skip forward or backwards entire pages. Spend some time with nano and its
help screen. To enter the help screen, press CTRL+G.
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 3 of 10
Lab – Working with Text Files in the CLI
c. Use cat command to display the contents of the .bashrc file. This file is used to configure user-specific
terminal behavior and customization.
[analyst@secOps ~]$cat .bashrc
export EDITOR=vim
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 4 of 10
Lab – Working with Text Files in the CLI
bash.bash_logoutinputrcmotdrpc
bash.bashrc iproute2 mtabrsyslog.conf
binfmt.diptablesnanorcsecuretty
ca-certificates issue netconfig security
crypttab java-7-openjdk netctl services
dbus-1 java-8-openjdk netsniff-ng shadow
default kernel nginx shadow-
depmod.d krb5.conf nscd.conf shells
dhcpcd.confld.so.cachensswitch.confskel
dhcpcd.duidld.so.confntp.confssh
dkmsld.so.conf.dopenldapssl
drirclibnlopenvswitchsudoers
elasticsearchlibpaper.dos-release sudoers.d
environmentlightdmpacman.confsudoers.pacnew
ethertypeslocale.confpacman.conf.pacnewsysctl.d
filebeatlocale.genpacman.dsystemd
fontslocale.gen.pacnewpam.dtmpfiles.d
fstablocaltimepango trusted-key.key
gai.conflogin.defspapersizeudev
gemrclogrotate.confpasswdUPower
grouplogrotate.dpasswd- vdpau_wrapper.cfg
group-logstashpcmciavimrc
group.pacnewlvm pkcs11 webapps
grub.d machine-id polkit-1 wgetrc
gshadowmail.rc profile X11
gshadow-makepkg.confprofile.dxdg
gshadow.pacnewman_db.conf protocols xinetd.d
gtk-2.0mdadm.conf pulse yaourtrc
gtk-3.0mime.typesrc_keymaps
e. Use the cat command to display the contents of the bash_bashrc file:
[analyst@secOps ~]$cat /etc/bash.bashrc
#
# /etc/bash.bashrc
#
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007"
"${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
;;
screen)
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\"
"${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 5 of 10
Lab – Working with Text Files in the CLI
;;
esac
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 6 of 10
Lab – Working with Text Files in the CLI
c. Because.bashrc is a hidden file with no extension, SciTE does not display it in the file list. If the Location
feature is not visible in the dialog box, Change the type of file shown by selecting All Files (*) from the
type drop box, as shown below. All the files in the analyst’s home directory are shown.
d. Select.bashrc and click Open.
e. Locate 32 and replace it with 31. 32 is the color code for green, while 31 represents red.
f. Save the file by selecting File > Save and close SciTE by clicking the X icon.
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 7 of 10
Lab – Working with Text Files in the CLI
g. Click the Terminal application icon located on the Dock, at the bottom center of the Cisco CyberOPS VM
screen. The prompt should appear in red instead of green.
Didthe terminal window which was already open also change color from green to red? Explain.
Answer :
Berubah menjadi merah. Baschnya di ganti menjadi 31 yaitu kode untuk warna merah.
h. The same change could have been made from the command line with a text editor such as nano. From a
new terminal window, type nano .bashrc to launch nano and automatically load the .bashrc file in it:
[analyst@secOps ~]$nano .bashrc
export EDITOR=vim
[ Read 5 lines ]
^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos
^X Exit ^R Read File ^\ Replace ^U Uncut Text^T To Spell ^_ Go To Line
i. Change 31 to 33. 33 is the color code to yellow.
j. Press CTRL+X to save and then press Y to confirm. Nano will also offer you the chance to change the
filename. Simply press ENTER to use the same name, .bashrc.
k. Nano will end, and you will be back on the shell prompt. Again, click the Terminal application icon located
on the Dock, at the bottom center of the Cisco CyberOps VM screen. The prompt should now appear in
yellow instead of red.
1
2 #user html;
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 8 of 10
Lab – Working with Text Files in the CLI
3 worker_processes 1;
4
5 #error_log logs/error.log;
6 #error_log logs/error.log notice;
7 #error_log logs/error.log info;
8
9 #pid logs/nginx.pid;
10
11
12 events {
13 worker_connections 1024;
14 }
15
16
17 http {
18 include mime.types;
19 default_type application/octet-stream;
20
21 #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
22 # '$status $body_bytes_sent "$http_referer" '
23 # '"$http_user_agent" "$http_x_forwarded_for"';
24
25 #access_log logs/access.log main;
26
27 sendfile on;
28 #tcp_nopush on;
29
30 #keepalive_timeout 0;
31 keepalive_timeout 65;
32
33 #gzip on;
34
35 types_hash_max_size 4096;
36 server_names_hash_bucket_size 128;
37
38 server {
39 listen 81;
40 server_name localhost;
41
42 #charset koi8-r;
43
44 #access_log logs/host.access.log main;
45
46 location / {
47 root /usr/share/nginx/html;
48 index index.html index.htm;
49 }
^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 9 of 10
Lab – Working with Text Files in the CLI
Reflection
Depending on the service, more options may be available for configuration.
Configuration file location, syntax, and available parameters will vary from service to service. Always consult
the documentation for information.
Permissions are a very common cause of problems. Make sure you have the correct permissions before
trying to edit configuration files.
More often than not, services must be restarted before the changes take effect.
© Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 10 of 10