What's new

Welcome to Ruzgar.com

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask questions and get answers from our community

Answer

Answer questions and become an expert on your topic

Contact us

Contact the site administrator directly.

Groups

Just like Facebook join them and enjoy.

Centos Lesson 2 Linux ip learning and File Listing, File Creation Commands

ruzgar

Administrator
Staff member
Joined
Oct 3, 2021
Messages
37
Reaction score
0
Points
6
Learning server ip, netmask and gateway:

With:
Code:
ifconfig
command you can view your network configuration.

After connecting to SSH, you can view the following settings by typing ifconfig and pressing Enter.

inet: is your server ip,
netmask is your gateway and
broadcast is your network output ip.

Linux file operations:

File Listing:

File listing file listings are generally done as
Code:
ls (options) (file or directory name)
.

  • ls: is the listing command. It is used frequently.
  • ls -a: Lists all files and directories.
  • ls -l Lists files by listing. For example
    Code:
    ls -l

1635186247363.png
  • ls -h: Shows files and sizes.
  • ls -o: Shows File Sizes with permissions
  • ls -R: All directories and subdirectories in the file are listed.
  • ls -t: Lists by last access date.
  • ls -1: Lists on a single sequence
  • ls -lh: An alternative to -l is more useful. It shows the file sizes in a way that we can read. Adds kb or GB instead of bytes)
  • ls -ld: Gives information about the current directory. Like file permissions, modification date.
  • ls -r: Listings are normally alphabetical. This command lists them in reverse alphabetical order.
  • ls -ltr: List means by time but in reverse.
File and Directory Creation:

File Creation:

Code:
pwd
command is used to see where you are in SSH.

1635186607364.png

Code:
cd /
code is used to go to the top directory.

touch command creates file, mkdir command creates directory.
Code:
touch [parameters] [filename]

As you can see, we have created a new folder named wind with the touch wind command below.

1635186683928.png

  • touch -a [filename]: Used for an existing file. Updates the file's access date.
  • touch -t YYYAAGGSSDD.SS [filename] allows the file's access to be updated for the desired date.
Indexing:

Indexing is done with the mkdir command. It has the following usage:

Code:
mkdir [parameter] [directoryname]

  • mkdir ruzgar: Creates a folder named ruzgar.
  • mkdir ruzgar1/ruzgar2: creates a folder named ruzgar1 and creates a folder named ruzgar2 inside it
  • mkdir -p folder1/folder2/folder3/folder4 : creates 4 directories named folder1, folder2, folder3 and folder4 to the folder you are in.
  • mkdir -m 777 /folder1: gives 777 permission to folder1. It's like the chmod code.
File Reading and Editing:

The cat command is used to read or edit files in Linux.
  • cat text.txt: It is provided to read the text file with the text name.
  • cat > text.txt : You start typing in the file with the command. You can finish typing with Ctrl+D.
  • cat >> text.txt: With the command, the contents of the file will not be deleted, you can write what you want to write in the last part.
  • cat text1.txt text2.txt > text3.txt: text1 and text2 combined and written as test3.
  • cat -n text.txt: shows the contents of the text file with 1 number on each line. Useful for programming.
  • cat -T text.txt: displays the TAB characters in the text file.
  • cat -E text.txt: shows line breaks in the text file.
  • cat -A text.txt: displays all special characters in the text file.
  • cat *: Displays all files in a directory.
  • cat *.jpg displays only kpg files.
  • tac text.txt: reverses the lines in the text file. (Does not change columns)
 

Attachments

  • 1635186009307.png
    1635186009307.png
    479.5 KB · Views: 0
shape1
shape2
shape3
shape4
shape5
shape6
Top