hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    arrow
    arrow
    arrow
    In Linux OS, which command is used to rename a file from oldname.txt to newname.txt ?
    Question

    In Linux OS, which command is used to rename a file from oldname.txt to newname.txt ?

    A.

    Create oldname.txt newname.txt

    B.

    touch oldname.txt newname.txt

    C.

    cp oldname.txt newname.txt

    D.

    mv oldname.txt newname.txt

    Correct option is D

    The correct answer is (D) mv oldname.txt newname.txt

    Explanation:
    • The **mv** (move) command is used in Linux to rename files and directories.

    • When used as mv oldname.txt newname.txt, it renames the file without creating a duplicate.

    • This command is efficient because it simply updates the file metadata without copying data.

    Information Booster:
    • mv is used for both moving and renaming files or directories.

    • Syntax: mv [source] [destination]

    • Example: mv notes.txt archive/ moves notes.txt into the archive folder.

    • No confirmation prompt is given by default; existing files may be overwritten unless -i (interactive) is used.

    Additional Information:
    • Option A – Create: Not a valid Linux command.

    • Option B – touch: Creates new empty files; cannot rename or move files.

    • Option C – cp: Copies the file to a new name but keeps the original file intact.

    Free Tests

    Free
    Must Attempt

    CBT-1 Full Mock Test 1

    languageIcon English
    • pdpQsnIcon100 Questions
    • pdpsheetsIcon100 Marks
    • timerIcon90 Mins
    languageIcon English
    Free
    Must Attempt

    RRB NTPC Graduate Level PYP (Held on 5 Jun 2025 S1)

    languageIcon English
    • pdpQsnIcon100 Questions
    • pdpsheetsIcon100 Marks
    • timerIcon90 Mins
    languageIcon English
    Free
    Must Attempt

    RRB NTPC UG Level PYP (Held on 7 Aug 2025 S1)

    languageIcon English
    • pdpQsnIcon100 Questions
    • pdpsheetsIcon100 Marks
    • timerIcon90 Mins
    languageIcon English
    test-prime-package

    Access ‘RRB NTPC’ Mock Tests with

    • 60000+ Mocks and Previous Year Papers
    • Unlimited Re-Attempts
    • Personalised Report Card
    • 500% Refund on Final Selection
    • Largest Community
    students-icon
    368k+ students have already unlocked exclusive benefits with Test Prime!
    Our Plans
    Monthsup-arrow